diff options
| author | Efraim Flashner <efraim@flashner.co.il> | 2026-02-24 12:46:06 +0200 |
|---|---|---|
| committer | Efraim Flashner <efraim@flashner.co.il> | 2026-02-24 15:14:45 +0200 |
| commit | 4e8c3a3434699b487521582d3039002d425a32bd (patch) | |
| tree | 1358e3480f1f860feab3c301af64c054f313ca02 /gnu | |
| parent | d7c540f45707f69949087ecf56be903b6f4c49a1 (diff) | |
gnu: starship: Rewrite install-completions phase.
* gnu/packages/shellutils.scm (starship)[arguments]: Rewrite the
'install-completions phase to be less manual.
Change-Id: I42e709dd95c1901f5de5d4dce7cb47c3546625cb
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/packages/shellutils.scm | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/gnu/packages/shellutils.scm b/gnu/packages/shellutils.scm index 43d7979700c..eceb879975f 100644 --- a/gnu/packages/shellutils.scm +++ b/gnu/packages/shellutils.scm @@ -523,42 +523,30 @@ POSIX Shell}, @url{https://www.gnu.org/software/bash/, Bash}, and (arguments (list #:install-source? #f + #:modules + '((guix build cargo-build-system) + (guix build utils) + (ice-9 match)) #:phases #~(modify-phases %standard-phases (add-after 'install 'install-completions - (lambda* (#:key native-inputs outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (starship-bin - (if #$(%current-target-system) - (search-input-file native-inputs "/bin/starship") - (string-append out "/bin/starship"))) - (share (string-append out "/share")) - (bash-completion-dir - (string-append out "/share/bash-completion/completions")) - (zsh-completion-dir - (string-append share "/zsh/site-functions/")) - (fish-completion-dir - (string-append share "/fish/vendor_completions.d/")) - (elvish-completion-dir - (string-append share "/elvish/lib"))) - ;; Make the directories - (mkdir-p bash-completion-dir) - (mkdir-p zsh-completion-dir) - (mkdir-p fish-completion-dir) - (mkdir-p elvish-completion-dir) - ;; Use the built starship to generate the completions. - (with-output-to-file - (string-append bash-completion-dir "/starship") - (lambda _ (invoke starship-bin "completions" "bash"))) - (with-output-to-file - (string-append zsh-completion-dir "/_starship") - (lambda _(invoke starship-bin "completions" "zsh"))) - (with-output-to-file - (string-append fish-completion-dir "/starship.fish") - (lambda _ (invoke starship-bin "completions" "fish"))) - (with-output-to-file - (string-append elvish-completion-dir "/starship") - (lambda _ (invoke starship-bin "completions" "elvish")))))) + (lambda* (#:key native-inputs #:allow-other-keys) + (for-each + (match-lambda + ((shell . path) + (mkdir-p (in-vicinity #$output (dirname path))) + (let ((binary + (if #$(%current-target-system) + (search-input-file native-inputs "bin/starship") + (in-vicinity #$output "bin/starship")))) + (with-output-to-file (in-vicinity #$output path) + (lambda _ + (invoke binary "completions" shell)))))) + '(("bash" . "share/bash-completion/completions/starship") + ("elvish" . "share/elvish/lib/starship") + ("fish" . "share/fish/vendor_completions.d/starship.fish") + ("nushell" . "share/nushell/vendor/autoload/starship") + ("zsh" . "share/zsh/site-functions/_starship"))))) ;; Some tests require a writable home directory (add-after 'unpack 'patch-test-shell (lambda* (#:key inputs #:allow-other-keys) |
