Environment variables: Difference between revisions
Add info about session variables and environment variables |
Added a way to fix "pam_env(sudo:session): Expandable variables must be wrapped in {}" Tags: Mobile edit Mobile web edit |
||
| (One intermediate revision by one other user not shown) | |||
| Line 55: | Line 55: | ||
==== Solution or workaround ==== | ==== Solution or workaround ==== | ||
Using Nix string literals can fix the problem by keeping the curly brackets after the nix evaluation. | |||
<syntaxhighlight lang="nix"> | |||
Value: | |||
{ | |||
... | |||
VARIABLE = ''''${VARIABLE}/path/to''; | |||
... | |||
} | |||
</syntaxhighlight> | |||
This will result in VARIABLE having the value <code>${VARIABLE}/path/to</code> | |||
For example: | |||
<syntaxhighlight lang="nix"> | |||
{ | |||
environment.sessionVariables = rec { | |||
XDG_CACHE_HOME = ''''${HOME}/.cache''; | |||
# ... | |||
}; | |||
# ... | |||
} | |||
</syntaxhighlight> | |||
== Using variables from a Nix expression == | == Using variables from a Nix expression == | ||
| Line 83: | Line 107: | ||
NIX_STORE=/nix/store | NIX_STORE=/nix/store | ||
</pre> | </pre> | ||
[[Category:NixOS]] | |||
[[Category:Configuration]] | |||