nixos/shells: enable to nullify already defined aliases
commitc941577dcb68ad413853ae744a458555b3209c21
authorMitsuhiro Nakamura <m.nacamura@gmail.com>
dateFri 12 Oct 2018, 22:58 (8 years ago)
parent3b5449b
nixos/modules/config/shells-environment.nix+3−2
@@ -108,13 +108,14 @@ in
108108 };
109109
110110 environment.shellAliases = mkOption {
111− example = { ll = "ls -l"; };
111+ example = { l = null; ll = "ls -l"; };
112112 description = ''
113113 An attribute set that maps aliases (the top level attribute names in
114114 this option) to command strings or directly to build outputs. The
115115 aliases are added to all users' shells.
116+ Aliases mapped to <code>null</code> are ignored.
116117 '';
117− type = with types; attrsOf (either str path);
118+ type = with types; attrsOf (nullOr (either str path));
118119 };
119120
120121 environment.binsh = mkOption {
nixos/modules/programs/bash/bash.nix+3−2
@@ -33,7 +33,8 @@ let
3333 '';
3434
3535 bashAliases = concatStringsSep "\n" (
36− mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
36+ mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
37+ (filterAttrs (k: v: !isNull v) cfg.shellAliases)
3738 );
3839
3940in
@@ -64,7 +65,7 @@ in
6465 Set of aliases for bash shell, which overrides <option>environment.shellAliases</option>.
6566 See <option>environment.shellAliases</option> for an option format description.
6667 '';
67− type = with types; attrsOf (either str path);
68+ type = with types; attrsOf (nullOr (either str path));
6869 };
6970
7071 shellInit = mkOption {
nixos/modules/programs/fish.nix+3−2
@@ -9,7 +9,8 @@ let
99 cfg = config.programs.fish;
1010
1111 fishAliases = concatStringsSep "\n" (
12− mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases
12+ mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}")
13+ (filterAttrs (k: v: !isNull v) cfg.shellAliases)
1314 );
1415
1516in
@@ -58,7 +59,7 @@ in
5859 Set of aliases for fish shell, which overrides <option>environment.shellAliases</option>.
5960 See <option>environment.shellAliases</option> for an option format description.
6061 '';
61− type = with types; attrsOf (either str path);
62+ type = with types; attrsOf (nullOr (either str path));
6263 };
6364
6465 shellInit = mkOption {
nixos/modules/programs/zsh/zsh.nix+3−2
@@ -11,7 +11,8 @@ let
1111 cfg = config.programs.zsh;
1212
1313 zshAliases = concatStringsSep "\n" (
14− mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
14+ mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
15+ (filterAttrs (k: v: !isNull v) cfg.shellAliases)
1516 );
1617
1718in
@@ -39,7 +40,7 @@ in
3940 Set of aliases for zsh shell, which overrides <option>environment.shellAliases</option>.
4041 See <option>environment.shellAliases</option> for an option format description.
4142 '';
42− type = with types; attrsOf (either str path);
43+ type = with types; attrsOf (nullOr (either str path));
4344 };
4445
4546 shellInit = mkOption {