summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/config/shells-environment.nix5
-rw-r--r--nixos/modules/programs/bash/bash.nix5
-rw-r--r--nixos/modules/programs/fish.nix5
-rw-r--r--nixos/modules/programs/zsh/zsh.nix5
4 files changed, 12 insertions, 8 deletions
diff --git a/nixos/modules/config/shells-environment.nix b/nixos/modules/config/shells-environment.nix
index a279120e125..6379b52870e 100644
--- a/nixos/modules/config/shells-environment.nix
+++ b/nixos/modules/config/shells-environment.nix
@@ -108,13 +108,14 @@ in
     };
 
     environment.shellAliases = mkOption {
-      example = { ll = "ls -l"; };
+      example = { l = null; ll = "ls -l"; };
       description = ''
         An attribute set that maps aliases (the top level attribute names in
         this option) to command strings or directly to build outputs. The
         aliases are added to all users' shells.
+        Aliases mapped to <code>null</code> are ignored.
       '';
-      type = with types; attrsOf (either str path);
+      type = with types; attrsOf (nullOr (either str path));
     };
 
     environment.binsh = mkOption {
diff --git a/nixos/modules/programs/bash/bash.nix b/nixos/modules/programs/bash/bash.nix
index aa524a333ee..0fbc77ea44c 100644
--- a/nixos/modules/programs/bash/bash.nix
+++ b/nixos/modules/programs/bash/bash.nix
@@ -33,7 +33,8 @@ let
   '';
 
   bashAliases = concatStringsSep "\n" (
-    mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
+    mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
+      (filterAttrs (k: v: !isNull v) cfg.shellAliases)
   );
 
 in
@@ -64,7 +65,7 @@ in
           Set of aliases for bash shell, which overrides <option>environment.shellAliases</option>.
           See <option>environment.shellAliases</option> for an option format description.
         '';
-        type = with types; attrsOf (either str path);
+        type = with types; attrsOf (nullOr (either str path));
       };
 
       shellInit = mkOption {
diff --git a/nixos/modules/programs/fish.nix b/nixos/modules/programs/fish.nix
index 82af9ecc561..b38af07b92c 100644
--- a/nixos/modules/programs/fish.nix
+++ b/nixos/modules/programs/fish.nix
@@ -9,7 +9,8 @@ let
   cfg = config.programs.fish;
 
   fishAliases = concatStringsSep "\n" (
-    mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases
+    mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}")
+      (filterAttrs (k: v: !isNull v) cfg.shellAliases)
   );
 
 in
@@ -58,7 +59,7 @@ in
           Set of aliases for fish shell, which overrides <option>environment.shellAliases</option>.
           See <option>environment.shellAliases</option> for an option format description.
         '';
-        type = with types; attrsOf (either str path);
+        type = with types; attrsOf (nullOr (either str path));
       };
 
       shellInit = mkOption {
diff --git a/nixos/modules/programs/zsh/zsh.nix b/nixos/modules/programs/zsh/zsh.nix
index 66ca5e5d4eb..164d8db5859 100644
--- a/nixos/modules/programs/zsh/zsh.nix
+++ b/nixos/modules/programs/zsh/zsh.nix
@@ -11,7 +11,8 @@ let
   cfg = config.programs.zsh;
 
   zshAliases = concatStringsSep "\n" (
-    mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
+    mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
+      (filterAttrs (k: v: !isNull v) cfg.shellAliases)
   );
 
 in
@@ -39,7 +40,7 @@ in
           Set of aliases for zsh shell, which overrides <option>environment.shellAliases</option>.
           See <option>environment.shellAliases</option> for an option format description.
         '';
-        type = with types; attrsOf (either str path);
+        type = with types; attrsOf (nullOr (either str path));
       };
 
       shellInit = mkOption {