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 (first (directory-files ambrevar/guix-channel-spec-directory 'full
(concat pattern "-channel")))) (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) (defun ambrevar/guix-install-manifest (&optional manifest channel)
"Install Guix manifest to `ambrevar/guix-extra-profiles'. "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 non-nil, then try to use a channel specification file from
`ambrevar/guix-channel-spec-directory' if any." `ambrevar/guix-channel-spec-directory' if any."
(interactive) (interactive)
(require 'init-eshell) ; For `ambrevar/prefer-eshell'.
(let* ((manifest-pair (ambrevar/guix-query-manifest manifest)) (let* ((manifest-pair (ambrevar/guix-query-manifest manifest))
(manifest-name (first manifest-pair)) (manifest-name (first manifest-pair))
(manifest (second 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 (make-directory (expand-file-name manifest-name
ambrevar/guix-extra-profiles) ambrevar/guix-extra-profiles)
'parents) 'parents)
(let ((eshell-buffer-name "*guix*")) (funcall (if ambrevar/prefer-eshell
(eshell) 'ambrevar/run-in-eshell
(when (eshell-interactive-process) 'ambrevar/run-in-shell)
(eshell t)) (string-join
(eshell-interrupt-process) (list guix " package" (concat " --manifest=" manifest)
(insert guix " package" (concat " --manifest=" manifest) (if (string= "default" manifest-name)
(if (string= "default" manifest-name) ""
"" (concat " --profile=" (expand-file-name ambrevar/guix-extra-profiles)
(concat " --profile=" (expand-file-name ambrevar/guix-extra-profiles) "/" manifest-name
"/" manifest-name "/" manifest-name)))))
"/" manifest-name)))
(eshell-send-input))
(unless channel (unless channel
;; TODO: Only do this when manifest install has succeeded. ;; TODO: Only do this when manifest install has succeeded.
(ambrevar/guix-save-channel-specs (ambrevar/guix-save-channel-specs