about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2024-06-06 15:22:21 +0200
committerGitHub <noreply@github.com>2024-06-06 15:22:21 +0200
commit345330c76868c0541a5d7e5557ccb5d268fd1fa2 (patch)
tree655fd9f863660407b2693c2a9c493817ee8a1ec2 /nixos/modules
parenta9e4bf3fc1cf0b3fa74ff9cefd8c49a51626d26b (diff)
parent1c60f0a9a01c35129ea42c5587a2db2742536122 (diff)
Merge pull request #291552 from SuperSandro2000/bash-completion-package-option
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/programs/bash/bash-completion.nix16
-rw-r--r--nixos/modules/programs/bash/bash.nix2
-rw-r--r--nixos/modules/programs/fzf.nix2
-rw-r--r--nixos/modules/services/system/nix-daemon.nix2
4 files changed, 14 insertions, 8 deletions
diff --git a/nixos/modules/programs/bash/bash-completion.nix b/nixos/modules/programs/bash/bash-completion.nix
index c973d36fdfbf0..f143361bc9331 100644
--- a/nixos/modules/programs/bash/bash-completion.nix
+++ b/nixos/modules/programs/bash/bash-completion.nix
@@ -1,16 +1,22 @@
 { config, lib, pkgs, ... }:
 
 let
-  enable = config.programs.bash.enableCompletion;
+  cfg = config.programs.bash;
 in
 {
-  options = {
-    programs.bash.enableCompletion = lib.mkEnableOption "Bash completion for all interactive bash shells" // {
+  options.programs.bash.completion = {
+    enable = lib.mkEnableOption "Bash completion for all interactive bash shells" // {
       default = true;
     };
+
+    package = lib.mkPackageOption pkgs "bash-completion" { };
   };
 
-  config = lib.mkIf enable {
+  imports = [
+    (lib.mkRenamedOptionModule [ "programs" "bash" "enableCompletion" ] [ "programs" "bash" "completion" "enable" ])
+  ];
+
+  config = lib.mkIf cfg.completion.enable {
     programs.bash.promptPluginInit = ''
       # Check whether we're running a version of Bash that has support for
       # programmable completion. If we do, enable all modules installed in
@@ -19,7 +25,7 @@ in
       # $XDG_DATA_DIRS/bash-completion/completions/
       # on demand, so they do not need to be sourced here.
       if shopt -q progcomp &>/dev/null; then
-        . "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
+        . "${cfg.completion.package}/etc/profile.d/bash_completion.sh"
         nullglobStatus=$(shopt -p nullglob)
         shopt -s nullglob
         for p in $NIX_PROFILES; do
diff --git a/nixos/modules/programs/bash/bash.nix b/nixos/modules/programs/bash/bash.nix
index 0f8c40da801b6..4c06f0aad9f81 100644
--- a/nixos/modules/programs/bash/bash.nix
+++ b/nixos/modules/programs/bash/bash.nix
@@ -198,7 +198,7 @@ in
 
     users.defaultUserShell = lib.mkDefault pkgs.bashInteractive;
 
-    environment.pathsToLink = lib.optionals cfg.enableCompletion [
+    environment.pathsToLink = lib.optionals cfg.completion.enable [
       "/etc/bash_completion.d"
       "/share/bash-completion"
     ];
diff --git a/nixos/modules/programs/fzf.nix b/nixos/modules/programs/fzf.nix
index 66ad7d418de68..b9258ab1e5052 100644
--- a/nixos/modules/programs/fzf.nix
+++ b/nixos/modules/programs/fzf.nix
@@ -15,7 +15,7 @@ in
     environment.systemPackages = lib.mkIf (cfg.keybindings || cfg.fuzzyCompletion) [ pkgs.fzf ];
 
     programs = {
-      # load after programs.bash.enableCompletion
+      # load after programs.bash.completion.enable
       bash.promptPluginInit = lib.mkAfter (lib.optionalString cfg.fuzzyCompletion ''
         source ${pkgs.fzf}/share/fzf/completion.bash
       '' + lib.optionalString cfg.keybindings ''
diff --git a/nixos/modules/services/system/nix-daemon.nix b/nixos/modules/services/system/nix-daemon.nix
index 0a5b0e2fcb80a..3d44bdac34bf6 100644
--- a/nixos/modules/services/system/nix-daemon.nix
+++ b/nixos/modules/services/system/nix-daemon.nix
@@ -164,7 +164,7 @@ in
         nixPackage
         pkgs.nix-info
       ]
-      ++ optional (config.programs.bash.enableCompletion) pkgs.nix-bash-completions;
+      ++ optional (config.programs.bash.completion.enable) pkgs.nix-bash-completions;
 
     systemd.packages = [ nixPackage ];