Emacs/Guix: Allow using M-x shell to install profiles.

master
Pierre Neidhardt 2020-06-09 10:41:51 +02:00
parent 95a98bd7c6
commit 293197b88f
1 changed files with 27 additions and 12 deletions

View File

@ -126,6 +126,22 @@ If MANIFEST is nil, it is queried from the manifests found in `ambrevar/guix-man
(first (directory-files ambrevar/guix-channel-spec-directory 'full
(concat pattern "-channel"))))
(defun ambrevar/run-in-eshell (command)
(let ((eshell-buffer-name "*guix*"))
(eshell)
(when (eshell-interactive-process)
(eshell t))
(eshell-interrupt-process)
(insert command)
(eshell-send-input)))
(defun ambrevar/run-in-shell (command)
(shell (generate-new-buffer (generate-new-buffer-name "*guix*")))
(goto-char (point-max))
(comint-delete-input)
(insert command)
(comint-send-input))
(defun ambrevar/guix-install-manifest (&optional manifest channel)
"Install Guix manifest to `ambrevar/guix-extra-profiles'.
@ -138,6 +154,7 @@ If CHANNEL is nil and `ambrevar/guix-always-use-channel-specs' is
non-nil, then try to use a channel specification file from
`ambrevar/guix-channel-spec-directory' if any."
(interactive)
(require 'init-eshell) ; For `ambrevar/prefer-eshell'.
(let* ((manifest-pair (ambrevar/guix-query-manifest manifest))
(manifest-name (first manifest-pair))
(manifest (second manifest-pair))
@ -159,18 +176,16 @@ non-nil, then try to use a channel specification file from
(make-directory (expand-file-name manifest-name
ambrevar/guix-extra-profiles)
'parents)
(let ((eshell-buffer-name "*guix*"))
(eshell)
(when (eshell-interactive-process)
(eshell t))
(eshell-interrupt-process)
(insert guix " package" (concat " --manifest=" manifest)
(if (string= "default" manifest-name)
""
(concat " --profile=" (expand-file-name ambrevar/guix-extra-profiles)
"/" manifest-name
"/" manifest-name)))
(eshell-send-input))
(funcall (if ambrevar/prefer-eshell
'ambrevar/run-in-eshell
'ambrevar/run-in-shell)
(string-join
(list guix " package" (concat " --manifest=" manifest)
(if (string= "default" manifest-name)
""
(concat " --profile=" (expand-file-name ambrevar/guix-extra-profiles)
"/" manifest-name
"/" manifest-name)))))
(unless channel
;; TODO: Only do this when manifest install has succeeded.
(ambrevar/guix-save-channel-specs