wiki/tools.nix.overrides-and-overlays.html
2022-07-29 15:41:17 +00:00

20 lines
7.1 KiB
HTML

<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Nix overrides and overlays</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: [ [&#x27;$&#x27;,&#x27;$&#x27;], [&#x27;\(&#x27;,&#x27;\)&#x27;] ],
displayMath: [ [&#x27;$$&#x27;,&#x27;$$&#x27;], [&#x27;[&#x27;,&#x27;]&#x27;] ]
},
options = {
processHtmlClass = &quot;math&quot;
}
}
</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>Nix overrides and overlays</h1><section class="post-metadata"><span>Date: <!-- -->2021-07-28 12:54:40 +08:00</span><span>Date modified: <!-- -->2021-07-28 12:55:03 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"></ol></nav><p>You can override values in Nix as a way to customize nixpkgs.
For example, if you want to use a different version from the nixpkgs channel, you can change the appropriate value.
</p><pre class="src-block"><code class="language-nix">let overlay = self: super:
{
ncmpcpp = super.ncmpcpp.override { visualizerSupport = true; };
}
</code></pre><p>For another example, you can see some examples from <a href="https://github.com/neovim/neovim/blob/f695457f815544d0dc16469569c70556e3165bb6/contrib/flake.nix">Neovim</a> and <a href="https://gitlab.com/veloren/veloren/-/tree/685f4971ac0deb31b301e9d2bc0201d2531fd895/nix">Veloren</a> (which also uses Nix flakes).
</p><p>You can set overlays automatically either by setting <code class="inline-verbatim">nixpkgs.overlays</code> from your system configuration or <code class="inline-verbatim">~/.config/nixpkgs/overlays/</code> folder for user-specific settings.
You could also set overlays for standalone Nix code similarly through the <code class="inline-verbatim">overlays</code> key — e.g., <code class="inline-code">import &lt;nixpkgs&gt; ? { overlays = (self: super: { } ); };</code>.
</p><section><h2>Backlinks</h2><ul><li><a href="/wiki/tools.nix">Nix package manager</a></li></ul></section></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"2021-07-28 12:54:40 +08:00","date_modified":"2021-07-28 12:55:03 +08:00","language":"en","source":""},"title":"Nix overrides and overlays","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":"You can override values in Nix as a way to customize nixpkgs.\nFor example, if you want to use a different version from the nixpkgs channel, you can change the appropriate value.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-nix"]},"children":[{"type":"text","value":"let overlay = self: super:\n {\n ncmpcpp = super.ncmpcpp.override { visualizerSupport = true; };\n }\n"}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"For another example, you can see some examples from "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/neovim/neovim/blob/f695457f815544d0dc16469569c70556e3165bb6/contrib/flake.nix"},"children":[{"type":"text","value":"Neovim"}]},{"type":"text","value":" and "},{"type":"element","tagName":"a","properties":{"href":"https://gitlab.com/veloren/veloren/-/tree/685f4971ac0deb31b301e9d2bc0201d2531fd895/nix"},"children":[{"type":"text","value":"Veloren"}]},{"type":"text","value":" (which also uses Nix flakes).\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can set overlays automatically either by setting "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"nixpkgs.overlays"}]},{"type":"text","value":" from your system configuration or "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"~/.config/nixpkgs/overlays/"}]},{"type":"text","value":" folder for user-specific settings.\nYou could also set overlays for standalone Nix code similarly through the "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"overlays"}]},{"type":"text","value":" key — e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"import \u003cnixpkgs\u003e ? { overlays = (self: super: { } ); };"}]},{"type":"text","value":".\n"}]}]},"backlinks":[{"path":"/tools.nix","title":"Nix package manager"}]},"__N_SSG":true},"page":"/[[...slug]]","query":{"slug":["tools.nix.overrides-and-overlays"]},"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/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" async=""></script><script src="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_buildManifest.js" async=""></script><script src="/wiki/_next/static/Ie9t5zutrXP6Of75Cb5xF/_ssgManifest.js" async=""></script></body></html>