[bug#77181,0/5] gnu: Fix bash completion directories.

Message ID Z-LHGMeTZHfkOTqE@3900XT
State New
Headers

Commit Message

Efraim Flashner March 25, 2025, 3:09 p.m. UTC
  On Sat, Mar 22, 2025 at 05:22:06PM +0000, 45mg wrote:
> Hi Ian,
> 
[...]
> 
> On Guix, we have:
> 
> --8<---------------cut here---------------start------------->8---
> # guix shell pkg-config bash-completion
> 
> [user@guix1 ]$ pkg-config --variable=completionsdir bash-completion
> /gnu/store/5774mb64pqw93fpcchndiiq9fh80ngga-bash-completion-2.11/share/bash-completion/completions
> 
> [user@guix1 ]$ pkg-config --variable=compatdir bash-completion
> /gnu/store/5774mb64pqw93fpcchndiiq9fh80ngga-bash-completion-2.11/etc/bash_completion.d
> --8<---------------cut here---------------end--------------->8---
> 
> So, it looks like we should ideally be installing into
> share/bash-completion/completions everywhere. etc/bash_completion.d will
> also work, but the former is preferred because completions will be
> loaded on-demand rather than eagerly. There are currently dozens of
> packages using the latter; maybe some of them have a reason to
> eager-load their completions.

I have the following diff I think will be useful.  Let me know what you
think.  We shouldn't need to duplicate the paths in all the packages.
  

Comments

45mg March 25, 2025, 3:32 p.m. UTC | #1
Efraim Flashner <efraim@flashner.co.il> writes:

>
> I have the following diff I think will be useful.  Let me know what you
> think.  We shouldn't need to duplicate the paths in all the packages.
>
> -- 
> Efraim Flashner   <efraim@flashner.co.il>   אפרים פלשנר
> GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
> Confidentiality cannot be guaranteed on emails sent or received unencrypted
> diff --git a/guix/utils.scm b/guix/utils.scm
> index c7c23d9d5ba..c0c044147e2 100644
> --- a/guix/utils.scm
> +++ b/guix/utils.scm
> @@ -149,6 +149,12 @@ (define-module (guix utils)
>              config-directory
>              cache-directory
>  
> +            bash-completion-dir
> +            fish-completion-dir
> +            zsh-completion-dir
> +            elvish-completion-dir
> +            nu-completion-dir
> +
>              readlink*
>              go-to-location
>              edit-expression
> @@ -1193,6 +1199,33 @@ (define-syntax current-source-directory
>            ;; raising an error would upset Geiser users
>            #f))))))
>  
> +
> +;;;
> +;;; Shell completion directories.
> +;;;
> +
> +(define bash-completion-dir
> +  ;; The standard directory for installing bash completions.
> +  ;; https://github.com/scop/bash-completion?tab=readme-ov-file#faq
> +  "/share/bash-completion/completions/")
> +
> +(define fish-completion-dir
> +  ;; The standard directory for installing fish completions.
> +  ;; https://fishshell.com/docs/current/completions.html#where-to-put-completions
> +  "/share/fish/vendor_completions.d/")
> +
> +(define zsh-completion-dir
> +  ;; The standard directory for installing zsh completions.
> +  "/share/zsh/site-functions/")
> +
> +(define elvish-completion-dir
> +  ;; The standard directory for installing elvish completions.
> +  "/share/elvish/lib/")
> +
> +(define nu-completion-dir
> +  ;; The standard directory for installing nushell completions.
> +  "/share/nushell/vendor/autoload/")
> +
>  
>  ;;;
>  ;;; String comparison.

Seems reasonable. I suppose we could use these variables for all
packages that already use these standard directories (lots of rebuilds
though!).

As for the ones that use eg. `/etc/bash_completion.d`, I think we should
probably leave those as they are, unless someone's willing to
investigate each one and make sure they don't need to eager-load their
completion scripts, or have some other reason to use that directory.
  

Patch

diff --git a/guix/utils.scm b/guix/utils.scm
index c7c23d9d5ba..c0c044147e2 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -149,6 +149,12 @@  (define-module (guix utils)
             config-directory
             cache-directory
 
+            bash-completion-dir
+            fish-completion-dir
+            zsh-completion-dir
+            elvish-completion-dir
+            nu-completion-dir
+
             readlink*
             go-to-location
             edit-expression
@@ -1193,6 +1199,33 @@  (define-syntax current-source-directory
           ;; raising an error would upset Geiser users
           #f))))))
 
+
+;;;
+;;; Shell completion directories.
+;;;
+
+(define bash-completion-dir
+  ;; The standard directory for installing bash completions.
+  ;; https://github.com/scop/bash-completion?tab=readme-ov-file#faq
+  "/share/bash-completion/completions/")
+
+(define fish-completion-dir
+  ;; The standard directory for installing fish completions.
+  ;; https://fishshell.com/docs/current/completions.html#where-to-put-completions
+  "/share/fish/vendor_completions.d/")
+
+(define zsh-completion-dir
+  ;; The standard directory for installing zsh completions.
+  "/share/zsh/site-functions/")
+
+(define elvish-completion-dir
+  ;; The standard directory for installing elvish completions.
+  "/share/elvish/lib/")
+
+(define nu-completion-dir
+  ;; The standard directory for installing nushell completions.
+  "/share/nushell/vendor/autoload/")
+
 
 ;;;
 ;;; String comparison.