Lint wpc-nix.el

- add "Code:" header
- replace forward-slash with dash
- prefer wpc-nix- prefix to nix/
This commit is contained in:
William Carroll 2020-08-31 14:09:24 +01:00
parent d98fa38aca
commit d813128e90

View file

@ -4,6 +4,8 @@
;;; Commentary: ;;; Commentary:
;; Configuration to support working with Nix. ;; Configuration to support working with Nix.
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies ;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -19,7 +21,7 @@
:mode "\\.nix\\'") :mode "\\.nix\\'")
;; TODO(wpcarro): Ensure the sub-process can resolve <briefcase>. ;; TODO(wpcarro): Ensure the sub-process can resolve <briefcase>.
(defun nix/rebuild-emacs () (defun wpc-nix-rebuild-emacs ()
"Use nix-env to rebuild wpcarros-emacs." "Use nix-env to rebuild wpcarros-emacs."
(interactive) (interactive)
(let* ((emacs (if (device/corporate?) "emacs.glinux" "emacs.nixos")) (let* ((emacs (if (device/corporate?) "emacs.glinux" "emacs.nixos"))
@ -31,32 +33,28 @@
"-f" "<briefcase>" "-iA" emacs) "-f" "<briefcase>" "-iA" emacs)
(display-buffer bname))) (display-buffer bname)))
(defun nix/home-manager-switch () (defun wpc-nix-home-manager-switch ()
"Use Nix to reconfigure the user environment." "Use Nix to reconfigure the user environment."
(interactive) (interactive)
(start-process "nix/home-manager-switch" "*nix/home-manager-switch*" (start-process "wpc-nix-home-manager-switch" "*wpc-nix-home-manager-switch*"
"home-manager" "home-manager"
"-I" (format "nixpkgs=%s" (f-expand "~/nixpkgs-channels")) "-I" (format "nixpkgs=%s" (f-expand "~/nixpkgs-channels"))
"-I" (format "home-manager=%s" (f-expand "~/home-manager")) "-I" (format "home-manager=%s" (f-expand "~/home-manager"))
"switch") "switch")
(display-buffer "*nix/home-manager-switch*")) (display-buffer "*wpc-nix-home-manager-switch*"))
(defun nix/sly-from-briefcase (attribute) (defun wpc-nix-sly-from-briefcase (attr)
"Start a Sly REPL configured with a Lisp matching a derivation "Start a Sly REPL configured using the derivation pointed at by ATTR.
from my monorepo.
This function was taken from @tazjin's depot and adapted for my monorepo. The derivation invokes nix.buildLisp.sbclWith and is built asynchronously.
The build output is included in the error thrown on build failures."
The derivation invokes nix.buildLisp.sbclWith and is built
asynchronously. The build output is included in the error
thrown on build failures."
(interactive "sAttribute: ") (interactive "sAttribute: ")
(lexical-let* ((outbuf (get-buffer-create (format "*briefcase-out/%s*" attribute))) (lexical-let* ((outbuf (get-buffer-create (format "*briefcase-out/%s*" attr)))
(errbuf (get-buffer-create (format "*briefcase-errors/%s*" attribute))) (errbuf (get-buffer-create (format "*briefcase-errors/%s*" attr)))
(expression (format "let briefcase = import <briefcase> {}; in briefcase.third_party.depot.nix.buildLisp.sbclWith [ briefcase.%s ]" attribute)) (expression (format "let briefcase = import <briefcase> {}; in briefcase.third_party.depot.nix.buildLisp.sbclWith [ briefcase.%s ]" attr))
(command (list "nix-build" "-E" expression))) (command (list "nix-build" "-E" expression)))
(message "Acquiring Lisp for <briefcase>.%s" attribute) (message "Acquiring Lisp for <briefcase>.%s" attr)
(make-process :name (format "nix-build/%s" attribute) (make-process :name (format "nix-build/%s" attr)
:buffer outbuf :buffer outbuf
:stderr errbuf :stderr errbuf
:command command :command command
@ -65,12 +63,15 @@ This function was taken from @tazjin's depot and adapted for my monorepo.
(unwind-protect (unwind-protect
(pcase event (pcase event
("finished\n" ("finished\n"
(let* ((outpath (s-trim (with-current-buffer outbuf (buffer-string)))) (let* ((outpath (s-trim (with-current-buffer outbuf
(buffer-string))))
(lisp-path (s-concat outpath "/bin/sbcl"))) (lisp-path (s-concat outpath "/bin/sbcl")))
(message "Acquired Lisp for <briefcase>.%s at %s" attribute lisp-path) (message "Acquired Lisp for <briefcase>.%s at %s"
attr lisp-path)
(sly lisp-path))) (sly lisp-path)))
(_ (with-current-buffer errbuf (_ (with-current-buffer errbuf
(error "Failed to build '%s':\n%s" attribute (buffer-string))))) (error "Failed to build '%s':\n%s" attr
(buffer-string)))))
(kill-buffer outbuf) (kill-buffer outbuf)
(kill-buffer errbuf)))))) (kill-buffer errbuf))))))