diff options
| author | Xinglu Chen <public@yoctocell.xyz> | 2021-10-30 12:42:44 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2021-10-31 00:51:06 +0200 |
| commit | ea19381bd9405bdb711c36b534e463fc7c8ca949 (patch) | |
| tree | 26cbfb0e562efec7a9f6eeb4d207b24e555c798e | |
| parent | 40acbaf0789d47464062622bef463921556c2235 (diff) | |
guix home: import: Call ‘local-file’ with ‘name’
Set the name of the file to just the basename of the file passed to
‘local-file’.
* guix/scripts/home/import.scm (basename+remove-dots): New procedure.
(generate-bash-configuration+modules): Use it.
* tests/home-import.scm (match-home-environment-bash-service): Adjust
accordingly.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
| -rw-r--r-- | guix/scripts/home/import.scm | 20 | ||||
| -rw-r--r-- | tests/home-import.scm | 3 |
2 files changed, 18 insertions, 5 deletions
diff --git a/guix/scripts/home/import.scm b/guix/scripts/home/import.scm index 6e3ed065d5f..a0022458f6e 100644 --- a/guix/scripts/home/import.scm +++ b/guix/scripts/home/import.scm | |||
| @@ -39,7 +39,16 @@ | |||
| 39 | ;;; | 39 | ;;; |
| 40 | ;;; Code: | 40 | ;;; Code: |
| 41 | 41 | ||
| 42 | 42 | (define (basename+remove-dots file-name) | |
| 43 | "Remove the dot from the dotfile FILE-NAME; replace the other dots in | ||
| 44 | FILE-NAME with \"-\", and return the basename of it." | ||
| 45 | (string-map (match-lambda | ||
| 46 | (#\. #\-) | ||
| 47 | (c c)) | ||
| 48 | (let ((base (basename file-name))) | ||
| 49 | (if (string-prefix? "." base) | ||
| 50 | (string-drop base 1) | ||
| 51 | base)))) | ||
| 43 | 52 | ||
| 44 | (define (generate-bash-configuration+modules destination-directory) | 53 | (define (generate-bash-configuration+modules destination-directory) |
| 45 | (define (destination-append path) | 54 | (define (destination-append path) |
| @@ -52,15 +61,18 @@ | |||
| 52 | (home-bash-configuration | 61 | (home-bash-configuration |
| 53 | ,@(if (file-exists? rc) | 62 | ,@(if (file-exists? rc) |
| 54 | `((bashrc | 63 | `((bashrc |
| 55 | (list (local-file ,rc)))) | 64 | (list (local-file ,rc |
| 65 | ,(basename+remove-dots rc))))) | ||
| 56 | '()) | 66 | '()) |
| 57 | ,@(if (file-exists? profile) | 67 | ,@(if (file-exists? profile) |
| 58 | `((bash-profile | 68 | `((bash-profile |
| 59 | (list (local-file ,profile)))) | 69 | (list (local-file ,profile |
| 70 | ,(basename+remove-dots profile))))) | ||
| 60 | '()) | 71 | '()) |
| 61 | ,@(if (file-exists? logout) | 72 | ,@(if (file-exists? logout) |
| 62 | `((bash-logout | 73 | `((bash-logout |
| 63 | (list (local-file ,logout)))) | 74 | (list (local-file ,logout |
| 75 | ,(basename+remove-dots logout))))) | ||
| 64 | '()))) | 76 | '()))) |
| 65 | (guix gexp) | 77 | (guix gexp) |
| 66 | (gnu home services shells)))) | 78 | (gnu home services shells)))) |
diff --git a/tests/home-import.scm b/tests/home-import.scm index 691e8196d6d..40d9547e8b0 100644 --- a/tests/home-import.scm +++ b/tests/home-import.scm | |||
| @@ -156,7 +156,8 @@ corresponding file." | |||
| 156 | 'home-bash-service-type | 156 | 'home-bash-service-type |
| 157 | ('home-bash-configuration | 157 | ('home-bash-configuration |
| 158 | ('bashrc | 158 | ('bashrc |
| 159 | ('list ('local-file "/tmp/guix-config/.bashrc")))))))))) | 159 | ('list ('local-file "/tmp/guix-config/.bashrc" |
| 160 | "bashrc")))))))))) | ||
| 160 | 161 | ||
| 161 | (test-assert "manifest->code: No services" | 162 | (test-assert "manifest->code: No services" |
| 162 | (eval-test-with-home-environment | 163 | (eval-test-with-home-environment |
