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.
This commit is contained in:
William Carroll 2020-04-02 14:50:53 +01:00
parent 86da482fbf
commit d12b8b3dcb

View file

@ -8,6 +8,8 @@
;; Dependencies ;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'device)
;; TODO: These may fail at startup. How can I make sure that the .envrc is ;; TODO: These may fail at startup. How can I make sure that the .envrc is
;; consulted when Emacs starts? ;; consulted when Emacs starts?
(prelude/assert (f-exists? (getenv "BRIEFCASE"))) (prelude/assert (f-exists? (getenv "BRIEFCASE")))
@ -24,13 +26,16 @@
(defun nix/rebuild-emacs () (defun nix/rebuild-emacs ()
"Use nix-env to rebuild wpcarros-emacs." "Use nix-env to rebuild wpcarros-emacs."
(interactive) (interactive)
(start-process "nix-build/<briefcase/emacs>" "*nix-build/<briefcase/emacs>*" (let* ((emacs (if (device/corporate?) "emacs.glinux" "emacs.nixos"))
"nix-env" (pname (format "nix-build <briefcase/%s>" emacs))
"-I" (format "nixpkgs=%s" (f-expand "~/nixpkgs")) (bname (format "*%s*" pname)))
"-I" (format "depot=%s" (f-expand "~/depot")) (start-process pname bname
"-I" (format "briefcase=%s" (f-expand "~/briefcase")) "nix-env"
"-f" "<briefcase>" "-iA" "emacs") "-I" (format "nixpkgs=%s" (f-expand "~/nixpkgs"))
(display-buffer "*nix-build/<briefcase/emacs>*")) "-I" (format "depot=%s" (f-expand "~/depot"))
"-I" (format "briefcase=%s" (f-expand "~/briefcase"))
"-f" "<briefcase>" "-iA" emacs)
(display-buffer bname)))
(defun nix/home-manager-switch () (defun nix/home-manager-switch ()
"Use Nix to reconfigure the user environment." "Use Nix to reconfigure the user environment."