From d12b8b3dcb97aa6365eca061a260b74b41bfd452 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Thu, 2 Apr 2020 14:50:53 +0100 Subject: [PATCH] Build either emacs.{glinux,nixos} depending on my current device `M-x nix/rebuild-emacs` will build either emacs.glinux or emacs.nixos depending on whether I'm using a work device or a personal device. --- emacs/.emacs.d/wpc/wpc-nix.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/emacs/.emacs.d/wpc/wpc-nix.el b/emacs/.emacs.d/wpc/wpc-nix.el index 1060645bb..b67a0f80f 100644 --- a/emacs/.emacs.d/wpc/wpc-nix.el +++ b/emacs/.emacs.d/wpc/wpc-nix.el @@ -8,6 +8,8 @@ ;; Dependencies ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(require 'device) + ;; TODO: These may fail at startup. How can I make sure that the .envrc is ;; consulted when Emacs starts? (prelude/assert (f-exists? (getenv "BRIEFCASE"))) @@ -24,13 +26,16 @@ (defun nix/rebuild-emacs () "Use nix-env to rebuild wpcarros-emacs." (interactive) - (start-process "nix-build/" "*nix-build/*" - "nix-env" - "-I" (format "nixpkgs=%s" (f-expand "~/nixpkgs")) - "-I" (format "depot=%s" (f-expand "~/depot")) - "-I" (format "briefcase=%s" (f-expand "~/briefcase")) - "-f" "" "-iA" "emacs") - (display-buffer "*nix-build/*")) + (let* ((emacs (if (device/corporate?) "emacs.glinux" "emacs.nixos")) + (pname (format "nix-build " emacs)) + (bname (format "*%s*" pname))) + (start-process pname bname + "nix-env" + "-I" (format "nixpkgs=%s" (f-expand "~/nixpkgs")) + "-I" (format "depot=%s" (f-expand "~/depot")) + "-I" (format "briefcase=%s" (f-expand "~/briefcase")) + "-f" "" "-iA" emacs) + (display-buffer bname))) (defun nix/home-manager-switch () "Use Nix to reconfigure the user environment."