summaryrefslogtreecommitdiff
path: root/modules/environment/default.nix
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-11-06 22:38:31 +0100
committerDaiderd Jordan <daiderd@gmail.com>2016-11-06 22:38:31 +0100
commit926395d628aa4cf9c96f234e5039a2d117d8f67a (patch)
tree565024322564530bfcb5cde3244519eeb15e2997 /modules/environment/default.nix
parent50081e675e947c6c4271bfcf0dca76e1379e16b4 (diff)
reorganize modules
Diffstat (limited to 'modules/environment/default.nix')
-rw-r--r--modules/environment/default.nix88
1 files changed, 88 insertions, 0 deletions
diff --git a/modules/environment/default.nix b/modules/environment/default.nix
new file mode 100644
index 0000000..37cd652
--- /dev/null
+++ b/modules/environment/default.nix
@@ -0,0 +1,88 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ cfg = config.environment;
+
+ exportVariables =
+ mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
+
+ aliasCommands =
+ mapAttrsFlatten (n: v: ''alias ${n}="${v}"'') cfg.shellAliases;
+
+
+in {
+ options = {
+
+ environment.systemPackages = mkOption {
+ type = types.listOf types.package;
+ default = [];
+ example = literalExample "[ pkgs.nix-repl pkgs.vim ]";
+ description = ''
+ The set of packages that appear in
+ /run/current-system/sw. These packages are
+ automatically available to all users, and are
+ automatically updated every time you rebuild the system
+ configuration. (The latter is the main difference with
+ installing them in the default profile,
+ <filename>/nix/var/nix/profiles/default</filename>.
+ '';
+ };
+
+ environment.systemPath = mkOption {
+ type = types.loeOf types.path;
+ default = [ "$HOME/.nix-profile" "/run/current-system/sw" "/nix/var/nix/profiles/default" "/usr/local" ];
+ description = ''
+ The set of paths that are added to PATH
+ '';
+ apply = x: if isList x then makeBinPath x else x;
+ };
+
+ environment.extraOutputsToInstall = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "doc" "info" "devdoc" ];
+ description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
+ };
+
+ environment.variables = mkOption {
+ type = types.attrsOf (types.loeOf types.str);
+ default = {};
+ description = ''
+ 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);
+ };
+
+ 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 = concatStringsSep "\n" exportVariables;
+ system.build.setAliases = concatStringsSep "\n" aliasCommands;
+
+ system.path = pkgs.buildEnv {
+ name = "system-path";
+ paths = cfg.systemPackages;
+ inherit (cfg) extraOutputsToInstall;
+ };
+
+ };
+}