summaryrefslogtreecommitdiff
path: root/modules/environment/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/environment/default.nix')
-rw-r--r--modules/environment/default.nix68
1 files changed, 40 insertions, 28 deletions
diff --git a/modules/environment/default.nix b/modules/environment/default.nix
index c4883c3..fc4db2a 100644
--- a/modules/environment/default.nix
+++ b/modules/environment/default.nix
@@ -9,19 +9,28 @@ let
mapAttrsToList (n: v: ''export ${n}="${v}"'') cfg.variables;
aliasCommands =
- mapAttrsFlatten (n: v: ''alias ${n}=${escapeShellArg v}'')
+ mapAttrsToList (n: v: ''alias ${n}=${escapeShellArg v}'')
(filterAttrs (k: v: v != null) cfg.shellAliases);
makeDrvBinPath = concatMapStringsSep ":" (p: if isDerivation p then "${p}/bin" else p);
in
{
+ imports = [
+ (mkRenamedOptionModule ["environment" "postBuild"] ["environment" "extraSetup"])
+ (mkRemovedOptionModule [ "environment" "loginShell" ] ''
+ This option was only used to change the default command in tmux.
+
+ This has been removed in favour of changing the default command or default shell in tmux directly.
+ '')
+ ];
+
options = {
environment.systemPackages = mkOption {
type = types.listOf types.package;
default = [];
example = literalExpression "[ pkgs.curl pkgs.vim ]";
- description = lib.mdDoc ''
+ description = ''
The set of packages that appear in
/run/current-system/sw. These packages are
automatically available to all users, and are
@@ -34,39 +43,33 @@ in
environment.systemPath = mkOption {
type = types.listOf (types.either types.path types.str);
- description = lib.mdDoc "The set of paths that are added to PATH.";
+ description = "The set of paths that are added to PATH.";
apply = x: if isList x then makeDrvBinPath x else x;
};
environment.profiles = mkOption {
type = types.listOf types.str;
- description = lib.mdDoc "A list of profiles used to setup the global environment.";
- };
-
- environment.postBuild = mkOption {
- type = types.lines;
- default = "";
- description = lib.mdDoc "Commands to execute when building the global environment.";
+ description = "A list of profiles used to setup the global environment.";
};
environment.extraOutputsToInstall = mkOption {
type = types.listOf types.str;
default = [];
example = [ "doc" "info" "devdoc" ];
- description = lib.mdDoc "List of additional package outputs to be symlinked into {file}`/run/current-system/sw`.";
+ description = "List of additional package outputs to be symlinked into {file}`/run/current-system/sw`.";
};
environment.pathsToLink = mkOption {
type = types.listOf types.str;
default = [];
example = [ "/share/doc" ];
- description = lib.mdDoc "List of directories to be symlinked in {file}`/run/current-system/sw`.";
+ description = "List of directories to be symlinked in {file}`/run/current-system/sw`.";
};
environment.darwinConfig = mkOption {
type = types.either types.path types.str;
default = "$HOME/.nixpkgs/darwin-configuration.nix";
- description = lib.mdDoc ''
+ description = ''
The path of the darwin configuration.nix used to configure the system,
this updates the default darwin-config entry in NIX_PATH. Since this
changes an environment variable it will only apply to new shells.
@@ -76,17 +79,11 @@ in
'';
};
- environment.loginShell = mkOption {
- type = types.str;
- default = "$SHELL -l";
- description = lib.mdDoc "Configure default login shell.";
- };
-
environment.variables = mkOption {
type = types.attrsOf (types.either types.str (types.listOf types.str));
default = {};
example = { EDITOR = "vim"; LANG = "nl_NL.UTF-8"; };
- description = lib.mdDoc ''
+ 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
@@ -100,7 +97,7 @@ in
type = types.attrsOf types.str;
default = {};
example = { ll = "ls -l"; };
- description = lib.mdDoc ''
+ 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.
@@ -110,7 +107,7 @@ in
environment.extraInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during global environment initialisation
after all variables and profileVariables have been set.
This code is asumed to be shell-independent, which means you should
@@ -120,7 +117,7 @@ in
environment.shellInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during shell initialisation.
This code is asumed to be shell-independent, which means you should
stick to pure sh without sh word split.
@@ -130,7 +127,7 @@ in
environment.loginShellInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during login shell initialisation.
This code is asumed to be shell-independent, which means you should
stick to pure sh without sh word split.
@@ -140,18 +137,32 @@ in
environment.interactiveShellInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during interactive shell initialisation.
This code is asumed to be shell-independent, which means you should
stick to pure sh without sh word split.
'';
type = types.lines;
};
+
+ environment.extraSetup = mkOption {
+ type = types.lines;
+ default = "";
+ description = ''
+ Shell fragments to be run after the system environment has been created.
+ This should only be used for things that need to modify the internals
+ of the environment, e.g. generating MIME caches.
+ The environment being built can be accessed at $out.
+ '';
+ };
};
config = {
- environment.systemPath = [ (makeBinPath cfg.profiles) "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ];
+ environment.systemPath = mkMerge [
+ [ (makeBinPath cfg.profiles) ]
+ (mkOrder 1200 [ "/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin" ])
+ ];
# Use user, default and system profiles.
environment.profiles = mkMerge [
@@ -185,7 +196,9 @@ in
system.path = pkgs.buildEnv {
name = "system-path";
paths = cfg.systemPackages;
- inherit (cfg) postBuild pathsToLink extraOutputsToInstall;
+ postBuild = cfg.extraSetup;
+ ignoreCollisions = true;
+ inherit (cfg) pathsToLink extraOutputsToInstall;
};
system.build.setEnvironment = pkgs.writeText "set-environment" ''
@@ -202,6 +215,5 @@ in
system.build.setAliases = pkgs.writeText "set-aliases" ''
${concatStringsSep "\n" aliasCommands}
'';
-
};
}