wiki/notebook/linux.systemd.environment-directives.org
2021-08-09 14:04:42 +08:00

1.0 KiB

systemd environment directives

systemd enables setting the environment through environment directives.

Just like how systemd at user-level, you can set it at user-level by placing them in certain user-level load paths (e.g., $XDG_CONFIG_HOME/environment.d).

It needs a *.conf file in one of the load paths (seen from the environment.d.5 manual page). Keep in mind it does not use the shell and instead makes use of shell-like syntax.

The following code block is an example of setting Nix-related environment variables to enable desktop integrations.

# Enable desktop integration with Nix-installed applications.
NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
PATH=${PATH:+$PATH:}$HOME/.nix-profile/bin
XDG_DATA_DIRS=${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}$HOME/.nix-profile/share/