mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 01:57:54 +00:00
22 lines
7.8 KiB
HTML
22 lines
7.8 KiB
HTML
|
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>systemd environment directives</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
|
||
|
MathJax = {
|
||
|
tex: {
|
||
|
inlineMath: [ ['$','$'], ['\(','\)'] ],
|
||
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
||
|
},
|
||
|
options = {
|
||
|
processHtmlClass = "math"
|
||
|
}
|
||
|
}
|
||
|
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>systemd environment directives</h1><section class="post-metadata"><span>Date: <!-- -->2021-08-07 19:58:29 +08:00</span><span>Date modified: <!-- -->2022-04-16 20:19:15 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"></ol></nav><p>systemd enables setting the environment through environment directives.
|
||
|
For some, this is a nice shell-agnostic way of setting environment variables and could replace setting through shell profiles (i.e., <code class="inline-verbatim">.bashrc</code>, <code class="inline-verbatim">.profile</code>).
|
||
|
</p><p>It needs a <code class="inline-verbatim">*.conf</code> file in one of the load paths (seen from the <code class="inline-verbatim">environment.d.5</code> manual page).
|
||
|
Just like how <a href="/wiki/linux.systemd#systemd-at-user-level">systemd at user-level</a>, you can set it at user-level by placing them in certain user-level load paths (e.g., <code class="inline-verbatim">$XDG_CONFIG_HOME/environment.d</code>).
|
||
|
</p><p>Keep in mind it does not use the shell directly and instead makes use of shell-like syntax.
|
||
|
The syntax takes variable substitutions and parameter expansion seen from <a href="id:dd9d3ffa-03ff-42a1-8c5d-55dc9fcc70fe">GNU Bash</a>.
|
||
|
</p><p>The following code block is an example of setting Nix-related environment variables to enable desktop integrations.
|
||
|
</p><pre class="src-block"><code class="language-ini"># 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/
|
||
|
</code></pre><section><h2>Backlinks</h2><ul><li><a href="/wiki/linux.systemd">systemd</a></li></ul></section></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"2021-08-07 19:58:29 +08:00","date_modified":"2022-04-16 20:19:15 +08:00","language":"en","source":""},"title":"systemd environment directives","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"systemd enables setting the environment through environment directives.\nFor some, this is a nice shell-agnostic way of setting environment variables and could replace setting through shell profiles (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":".bashrc"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":".profile"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It needs a "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"*.conf"}]},{"type":"text","value":" file in one of the load paths (seen from the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"environment.d.5"}]},{"type":"text","value":" manual page).\nJust like how "},{"type":"element","tagName":"a","properties":{"href":"/linux.systemd#systemd-at-user-level"},"children":[{"type":"text","value":"systemd at user-level"}]},{"type":"text","value":", you can set it at user-level by placing them in certain user-level load paths (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"$XDG_CONFIG_HOME/environment.d"}]},{"type":"text","value":").\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Keep in mind it does not use the shell directly and instead makes use of shell-like syntax.\nThe syntax takes variable substitutions and parameter expansion seen from "},{"type":"element","tagName":"a","properties":{"href":"id:dd9d3ffa-03ff-42a1-8c5d-55dc9fcc70fe"},"children":[{"type":"text","value":"GNU Bash"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The following code block is an example of setting Nix-related environment variables to enable desktop integrations.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-ini"]},"children":[{"type":"text","value":"# Enable desktop integration with Nix-installed applications.\nNIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH\nPATH=${PATH:+$PATH:}$HOME/.nix-profile/bin\nXDG_DATA_DIRS=${XDG_DATA_DIRS:+$XDG_DATA_DIRS:}$HOME/.nix-profile/share/\n"}]}]}]},"backlinks":[{"path":"/linux.systemd","title":"systemd"}]},"__N_SSG":true},"page":"/[[...slug]]","query":{"slug":["linux.systemd.environment-directives"]},"buildId":"Ie9t5zutrXP6Of75Cb5xF","assetPrefix":"/wiki","nextExport":false,"isFallback":false,"gsp":true}</script><script nomodule="" src="/wiki/_next/static/chunks/polyfills-99d808df29361cf7ffb1.js"></script><script src="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" async=""></script><script src="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" async=""></script><script src="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" async=""></script><script src="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" async=""></script><script src="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" async=""></script><script src="/wiki/_next/static/chunks/940643274e6
|