summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-10-21 20:56:23 +0200
committerDaiderd Jordan <daiderd@gmail.com>2016-10-21 20:56:23 +0200
commite968db6224c7a4ba7a36fab7aec8231c0e1c8aba (patch)
tree1b4a5e0e408b068a25718bf1227e550532320415 /modules
parentc02f1dc81f872fd08c3b12346dace1ec9bf278e3 (diff)
add environment.shellAliases
Diffstat (limited to 'modules')
-rw-r--r--modules/environment.nix23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules/environment.nix b/modules/environment.nix
index ace1b1c..d2e0d14 100644
--- a/modules/environment.nix
+++ b/modules/environment.nix
@@ -9,8 +9,9 @@ let
exportVariables =
mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
- exportedEnvVars =
- concatStringsSep "\n" exportVariables;
+ aliasCommands =
+ mapAttrsFlatten (n: v: ''alias ${n}="${v}"'') cfg.shellAliases;
+
in {
options = {
@@ -50,14 +51,26 @@ in {
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
};
+ environment.shellAliases = mkOption {
+ type = types.attrsOf types.str;
+ default = {};
+ example = { 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
+ alises are added to all users' shells.
+ '';
+ };
};
config = {
- system.build.setEnvironment = pkgs.writeText "set-environment" ''
- ${exportedEnvVars}
- '';
+ system.build.setEnvironment = pkgs.writeText "set-environment"
+ (concatStringsSep "\n" exportVariables);
+
+ system.build.setAliases = pkgs.writeText "set-aliases"
+ (concatStringsSep "\n" aliasCommands);
system.path = pkgs.buildEnv {
name = "system-path";