diff options
author | Xinglu Chen <public@yoctocell.xyz> | 2021-10-30 12:42:27 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-10-31 00:51:05 +0200 |
commit | d5eb05f01ea59da8435e9df4f15835edbb31a30e (patch) | |
tree | 6a5d9a5f7bb39228dced2cb956138720e87463e0 /guix/scripts/home.scm | |
parent | cf0abb6cfe5222796b676fe2d1c7667fb396ce14 (diff) | |
download | guix-patches-d5eb05f01ea59da8435e9df4f15835edbb31a30e.tar guix-patches-d5eb05f01ea59da8435e9df4f15835edbb31a30e.tar.gz |
guix home: import: Make the user to specify a destination directory.
Copy the appropriate the relevant configuration files to the destination
directory, and call ‘local-file’ on them.
Without this, ‘guix home import’ will generate a service declaration like this
(service
home-bash-service-type
(home-bash-configuration
(bashrc
(list (slurp-file-gexp
(local-file "/home/yoctocell/.bashrc"))))))
but when running ‘guix home reconfigure’, the ~/.bashrc file would be moved, so
when running ‘guix home reconfigure’ for the second time, it would read the
~/.bashrc which is itself a symlink to a file the store.
* guix/scripts/home/import.scm (generate-bash-module+configuration): Take
‘destination-directory’ parameter
(modules+configurations): Copy the user’s configuration file to
‘%destination-directory’.
* guix/scripts/home.scm (process-command): Adjust accordingly; create
‘destination’ if it doesn’t exist.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'guix/scripts/home.scm')
-rw-r--r-- | guix/scripts/home.scm | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 55e7b436c1..3f48b98ed4 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -40,6 +40,7 @@ #:autoload (guix scripts pull) (channel-commit-hyperlink) #:use-module (guix scripts home import) #:use-module ((guix status) #:select (with-status-verbosity)) + #:use-module ((guix build utils) #:select (mkdir-p)) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (srfi srfi-1) @@ -260,15 +261,20 @@ argument list and OPTS is the option alist." (apply search args)) ((import) (let* ((profiles (delete-duplicates - (match (filter-map (match-lambda - (('profile . p) p) - (_ #f)) - opts) - (() (list %current-profile)) - (lst (reverse lst))))) - (manifest (concatenate-manifests - (map profile-manifest profiles)))) - (import-manifest manifest (current-output-port)))) + (match (filter-map (match-lambda + (('profile . p) p) + (_ #f)) + opts) + (() (list %current-profile)) + (lst (reverse lst))))) + (manifest (concatenate-manifests + (map profile-manifest profiles))) + (destination (match args + ((destination) destination) + (_ (leave (G_ "wrong number of arguments~%")))))) + (unless (file-exists? destination) + (mkdir-p destination)) + (import-manifest manifest destination (current-output-port)))) ((describe) (match (generation-number %guix-home) (0 |