Emacs/Guix: Add system editing command.
parent
ef2105d0e7
commit
b10dd1942a
|
@ -50,6 +50,7 @@ with previous."
|
|||
(defvar ambrevar/guix-extra-channels "~/.guix-extra-channels")
|
||||
(defvar ambrevar/guix-extra-profiles "~/.guix-extra-profiles")
|
||||
(defvar ambrevar/guix-manifest-directory "~/.package-lists")
|
||||
(defvar ambrevar/guix-system-directory "~/.config/guix/system")
|
||||
(defvar ambrevar/guix-channel-spec-directory "~/.package-lists")
|
||||
(defvar ambrevar/guix-always-use-channel-specs nil
|
||||
"If non-nil, automatically use a channel specification matching the chosen manifest.
|
||||
|
@ -64,7 +65,7 @@ The channel specification is looked up in
|
|||
"Query a file matching FILTER in DIRECTORY.
|
||||
Return (NAME FILE).
|
||||
If FILE is non-nil, then this function is useful to derive the name of the manifest.
|
||||
NAME-FUNCTION take the file base name as argument and returns NAME.
|
||||
NAME-FUNCTION takes the file base name as argument and returns NAME.
|
||||
If MULTIPLE? is non-nil, return a list of (NAME FILE) of the selected manifests."
|
||||
(cl-flet ((name (file)
|
||||
(replace-regexp-in-string
|
||||
|
@ -97,6 +98,16 @@ If MULTIPLE? is non-nil, allow querying multiple manifests."
|
|||
(replace-regexp-in-string "-?manifest-?" "" name))
|
||||
:multiple? multiple?))
|
||||
|
||||
(defun ambrevar/guix-query-system (&optional system)
|
||||
"Query a system as found in `ambrevar/guix-system-directory'.
|
||||
Return (NAME FILE).
|
||||
If SYSTEM is non-nil, then this function is useful to derive the name of the system. "
|
||||
(ambrevar/guix-query-file
|
||||
:file system
|
||||
:directory ambrevar/guix-system-directory
|
||||
:filter "scm"
|
||||
:prompt "System: "))
|
||||
|
||||
(defun ambrevar/guix-query-channel-spec (&optional channel-spec)
|
||||
"Query a channel specification as found in `ambrevar/guix-channel-spec-directory'.
|
||||
Return (NAME FILE).
|
||||
|
@ -110,6 +121,18 @@ the channel specification."
|
|||
:name-function (lambda (name)
|
||||
(replace-regexp-in-string "-?channels?-?" "" name))))
|
||||
|
||||
(defun ambrevar/guix-edit-system (&optional system)
|
||||
"Edit system.
|
||||
If SYSTEM is nil, it is queried from the systems found in `ambrevar/guix-system-directory'."
|
||||
(interactive)
|
||||
(setq system (second (ambrevar/guix-query-system system)))
|
||||
(find-file system))
|
||||
(global-set-key (kbd "C-x c s") #'ambrevar/guix-edit-system)
|
||||
(with-eval-after-load 'evil
|
||||
;; For some reason `global-set-key' does not work for Evil at this point.
|
||||
(dolist (mode '(normal insert))
|
||||
(evil-global-set-key mode (kbd "C-x c s") #'ambrevar/guix-edit-system)))
|
||||
|
||||
(defun ambrevar/guix-edit-manifest (&optional manifest)
|
||||
"Edit MANIFEST.
|
||||
If MANIFEST is nil, it is queried from the manifests found in `ambrevar/guix-manifest-directory'."
|
||||
|
|
Loading…
Reference in New Issue