Environment variables: Difference between revisions

From NixOS Wiki
imported>Yuu
No edit summary
imported>Yuu
No edit summary
Line 21: Line 21:
}
}
</syntaxhighlight>
</syntaxhighlight>
= Troubleshooting =
== sudo[3424]: pam_env(sudo:session): Expandable variables must be wrapped in {} <$ENVIRONMENT_VARIABLE/path/to> - ignoring ==
=== Description ===
Error logs may be found with <code>journalctl -xb -p3</code> regarding the no presence of curly braces <code>{}</code> for variable expansion.
<syntaxhighlight lang="shell">
sudo[3424]: pam_env(sudo:session): Expandable variables must be wrapped in {} <$ENVIRONMENT_VARIABLE/path/to> - ignoring
<syntaxhighlight lang="shell">
While checking the configuration values, for instance with <code>nixos-option environment.sessionVariables</code>, it might be found that Nix is correctly parsing the curly braces.
<syntaxhighlight lang="nix">
Value:
{
  ...
  ENVIRONMENT_VARIABLE = "${ENVIRONMENT_VARIABLE}/path/to";
  ...
}
<\syntaxhighlight>
This indicates that the curly braces are getting removed at a later stage.
=== Solution or workaround ===
Unknown.

Revision as of 16:35, 8 July 2021

Defining environment variables

Environment variables can be set with environment.variables, environment.sessionVariables, and environment.profileRelativeSessionVariables. For example, for the XDG Base Directory Specification, the following could be set to /etc/nixos/configuration.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}"
    ];
  };

 # ...
}

Troubleshooting

sudo[3424]: pam_env(sudo:session): Expandable variables must be wrapped in {} <$ENVIRONMENT_VARIABLE/path/to> - ignoring

Description

Error logs may be found with journalctl -xb -p3 regarding the no presence of curly braces {} for variable expansion.

<syntaxhighlight lang="shell"> sudo[3424]: pam_env(sudo:session): Expandable variables must be wrapped in {} <$ENVIRONMENT_VARIABLE/path/to> - ignoring <syntaxhighlight lang="shell">

While checking the configuration values, for instance with nixos-option environment.sessionVariables, it might be found that Nix is correctly parsing the curly braces.

<syntaxhighlight lang="nix"> Value: {

 ...
 ENVIRONMENT_VARIABLE = "${ENVIRONMENT_VARIABLE}/path/to";
 ...

} <\syntaxhighlight>

This indicates that the curly braces are getting removed at a later stage.

Solution or workaround

Unknown.