Environment variables

From NixOS Wiki
Revision as of 16:13, 8 July 2021 by imported>Yuu (Created page with "= Defining environment variables = Environment variables can be set with <code/>environment.variables</code>, <code>environment.sessionVariables</code>, and <code>environment....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Defining environment variables

Environment variables can be set with environment.variables, environment.sessionVariables, and environment.profileRelativeSessionVariables. For example, for the Base Directory Specification, the following could be set to /etc/nixos/configuration.nix:

<syntaxhighlight lang="nix"> {

# ...
 environment.sessionVariables = rec {
   XDG_CACHE_HOME  = "\${HOME}/.cache";
   XDG_CONFIG_HOME = "\${HOME}/.config";
   XDG_BIN_HOME    = "\${HOME}/.local/bin";
   XDG_DATA_HOME   = "\${HOME}/.local/share";
   PATH = [ 
     "\${XDG_BIN_HOME}"
   ];
 };
# ...

}