summaryrefslogtreecommitdiff
path: root/modules/programs
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-12-17 23:11:35 +0100
committerDaiderd Jordan <daiderd@gmail.com>2016-12-17 23:11:35 +0100
commit0c4fbaf0d94b7de981ef798cedad2fa4ca03caed (patch)
tree3497676ef7afe22d81f89f25c1749153ba2f1bec /modules/programs
parent2ad1229c71fe5858fd4fa15b963198945ed01810 (diff)
add variables option to programs.zsh module
Diffstat (limited to 'modules/programs')
-rw-r--r--modules/programs/bash.nix12
-rw-r--r--modules/programs/zsh.nix22
2 files changed, 18 insertions, 16 deletions
diff --git a/modules/programs/bash.nix b/modules/programs/bash.nix
index 2231401..7a021ff 100644
--- a/modules/programs/bash.nix
+++ b/modules/programs/bash.nix
@@ -6,7 +6,7 @@ let
cfg = config.programs.bash;
- bash = pkgs.runCommand pkgs.zsh.name
+ shell = pkgs.runCommand pkgs.zsh.name
{ buildInputs = [ pkgs.makeWrapper ]; }
''
source $stdenv/setup
@@ -39,14 +39,6 @@ in
'';
};
- programs.bash.shell = mkOption {
- type = types.path;
- default = "${bash}/bin/bash";
- description = ''
- Zsh shell to use.
- '';
- };
-
programs.bash.interactiveShellInit = mkOption {
default = "";
description = ''
@@ -64,7 +56,7 @@ in
pkgs.bash
];
- environment.variables.SHELL = mkDefault "${cfg.shell}";
+ environment.variables.SHELL = mkDefault "${shell}/bin/bash";
environment.etc."bashrc".text = ''
# /etc/bashrc: DO NOT EDIT -- this file has been generated automatically.
diff --git a/modules/programs/zsh.nix b/modules/programs/zsh.nix
index 1990e4d..aeea21d 100644
--- a/modules/programs/zsh.nix
+++ b/modules/programs/zsh.nix
@@ -6,7 +6,10 @@ let
cfg = config.programs.zsh;
- zsh = pkgs.runCommand pkgs.zsh.name
+ zshVariables =
+ mapAttrsToList (n: v: ''${n}="${v}"'') cfg.variables;
+
+ shell = pkgs.runCommand pkgs.zsh.name
{ buildInputs = [ pkgs.makeWrapper ]; }
''
source $stdenv/setup
@@ -55,12 +58,17 @@ in
'';
};
- programs.zsh.shell = mkOption {
- type = types.path;
- default = "${zsh}/bin/zsh";
+ programs.zsh.variables = mkOption {
+ type = types.attrsOf (types.either types.str (types.listOf types.str));
+ default = {};
description = ''
- Zsh shell to use.
+ A set of environment variables used in the global environment.
+ These variables will be set on shell initialisation.
+ The value of each variable can be either a string or a list of
+ strings. The latter is concatenated, interspersed with colon
+ characters.
'';
+ apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
programs.zsh.shellInit = mkOption {
@@ -120,7 +128,7 @@ in
pkgs.zsh
];
- environment.variables.SHELL = mkDefault "${cfg.shell}";
+ environment.variables.SHELL = mkDefault "${shell}/bin/zsh";
environment.etc."zshenv".text = ''
# /etc/zshenv: DO NOT EDIT -- this file has been generated automatically.
@@ -147,6 +155,8 @@ in
if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi
__ETC_ZPROFILE_SOURCED=1
+ ${concatStringsSep "\n" zshVariables}
+
${cfg.loginShellInit}
# Read system-wide modifications.