mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-02-23 09:19:00 +00:00
27 lines
14 KiB
HTML
27 lines
14 KiB
HTML
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Nix packages</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>Nix packages</h1><section class="post-metadata"><span>Date: <!-- -->2021-07-18 21:23:26 +08:00</span><span>Date modified: <!-- -->2021-12-12 23:48:08 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/packages.nix#ecosystems" class="toc-link toc-link-h1">Ecosystems</a></li></ol></nav><ul><li><p>the most important component managed with <a href="/wiki/tools.nix">Nix package manager</a> are <a href="/wiki/tools.nix.derivations">Nix derivations</a></p></li><li><p>derivations are basically recipes how the Nix build daemon compiles the package
|
|
</p></li><li><p>most derivations are verbose but we can easily create one with nixpkgs
|
|
</p></li><li><p>for certain setups such as common conventions for certain programming languages like Rust and Go, nixpkgs has <a href="https://nixos.org/manual/nixpkgs/unstable/#chap-language-support">environments created for those</a>;
|
|
different versions may have changes so be sure to go into the appropriate documentation and create packages for a specific channel;
|
|
this is significantly easier with <a href="/wiki/tools.nix.flakes">Nix flakes</a></p></li></ul><h1 id="ecosystems">Ecosystems</h1><ul><li><p>while derivations can be interacted with the builtin function <code class="inline-verbatim">builtins.derivation</code>, it isn't really recommended since it is very verbose;
|
|
instead, you use <code class="inline-verbatim">stdenv.mkDerivation</code> from nixpkgs
|
|
</p></li><li><p>nixpkgs is the official repository of NixOS containing the standard library extending the <a href="/wiki/lang.nix">Nix language</a>, the largest repository of packages (counting up to 80,000 as of 2021-12-12), and various NixOS modules used to build the system itself
|
|
</p></li><li><p>nixpkgs contains <code class="inline-verbatim">stdenv</code> which is a derivation meant to be a base for other packages
|
|
</p><ul><li><p>stdenv contains base packages that virtually all packages have (inside nixpkgs)
|
|
</p></li><li><p></p></li></ul></li><li><p><code class="inline-verbatim">stdenv.mkDerivation</code> is a convenient way of creating derivations;
|
|
however, it is very abstract and a lot of events happening around it
|
|
</p><ul><li><p>this is a function that accepts a large attribute set
|
|
</p></li><li><p>it will map its arguments corresponding to a parameter in the final derivation made with <code class="inline-verbatim">stdenv</code> (which is a shell script)
|
|
</p></li><li><p>attributes are usually just variables;
|
|
this is especially prevelant if
|
|
</p></li><li><p>packages can also set setup hooks (i.e., <code class="inline-verbatim">setupHook</code>) that are essentially shell scripts to be added in the final derivation
|
|
</p><ul><li><p>example: <a href="https://github.com/NixOS/nixpkgs/tree/nixos-21.11/pkgs/development/tools/build-managers/cmake">cmake</a>, <a href="https://github.com/NixOS/nixpkgs/tree/nixos-21.11/pkgs/development/libraries/glib">glib</a>, and <a href="https://github.com/NixOS/nixpkgs/tree/nixos-21.11/pkgs/development/tools/build-managers">most of the build systems at nixpkgs</a></p></li></ul></li></ul></li></ul><section><h2>Backlinks</h2><ul><li><a href="/wiki/packages.flatpak">Flatpak packages</a></li><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-18 21:23:26 +08:00","date_modified":"2021-12-12 23:48:08 +08:00","language":"en","source":""},"title":"Nix packages","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":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"ecosystems"},"children":[{"type":"text","value":"Ecosystems"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/packages.nix#ecosystems"},"children":[{"type":"text","value":"Ecosystems"}]}]}]}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"the most important component managed with "},{"type":"element","tagName":"a","properties":{"href":"/tools.nix"},"children":[{"type":"text","value":"Nix package manager"}]},{"type":"text","value":" are "},{"type":"element","tagName":"a","properties":{"href":"/tools.nix.derivations"},"children":[{"type":"text","value":"Nix derivations"}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"derivations are basically recipes how the Nix build daemon compiles the package\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"most derivations are verbose but we can easily create one with nixpkgs\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"for certain setups such as common conventions for certain programming languages like Rust and Go, nixpkgs has "},{"type":"element","tagName":"a","properties":{"href":"https://nixos.org/manual/nixpkgs/unstable/#chap-language-support"},"children":[{"type":"text","value":"environments created for those"}]},{"type":"text","value":";\n different versions may have changes so be sure to go into the appropriate documentation and create packages for a specific channel;\n this is significantly easier with "},{"type":"element","tagName":"a","properties":{"href":"/tools.nix.flakes"},"children":[{"type":"text","value":"Nix flakes"}]}]}]}]},{"type":"element","tagName":"h1","properties":{"id":"ecosystems"},"children":[{"type":"text","value":"Ecosystems"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"while derivations can be interacted with the builtin function "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"builtins.derivation"}]},{"type":"text","value":", it isn't really recommended since it is very verbose;\n instead, you use "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"stdenv.mkDerivation"}]},{"type":"text","value":" from nixpkgs\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"nixpkgs is the official repository of NixOS containing the standard library extending the "},{"type":"element","tagName":"a","properties":{"href":"/lang.nix"},"children":[{"type":"text","value":"Nix language"}]},{"type":"text","value":", the largest repository of packages (counting up to 80,000 as of 2021-12-12), and various NixOS modules used to build the system itself\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"nixpkgs contains "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"stdenv"}]},{"type":"text","value":" which is a derivation meant to be a base for other packages\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"stdenv contains base packages that virtually all packages have (inside nixpkgs)\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[]}]}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"stdenv.mkDerivation"}]},{"type":"text","value":" is a convenient way of creating derivations;\n however, it is very abstract and a lot of events happening around it\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"this is a function that accepts a large attribute set\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"it will map its arguments corresponding to a parameter in the final derivation made with "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"stdenv"}]},{"type":"text","value":" (which is a shell script)\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"attributes are usually just variables;\n this is especially prevelant if\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"packages can also set setup hooks (i.e., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"setupHook"}]},{"type":"text","value":") that are essentially shell scripts to be added in the final derivation\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"example: "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/NixOS/nixpkgs/tree/nixos-21.11/pkgs/development/tools/build-managers/cmake"},"children":[{"type":"text","value":"cmake"}]},{"type":"text","value":", "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/NixOS/nixpkgs/tree/nixos-21.11/pkgs/development/libraries/glib"},"children":[{"type":"text","value":"glib"}]},{"type":"text","value":", and "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/NixOS/nixpkgs/tree/nixos-21.11/pkgs/development/tools/build-managers"},"children":[{"type":"text","value":"most of the build systems at nixpkgs"}]}]}]}]}]}]}]}]}]},"backlinks":[{"path":"/packages.flatpak","title":"Flatpak packages"},{"path":"/tools.nix","title":"Nix package manager"}]},"__N_SSG":true},"page":"/[[...slug]]","query":{"slug":["packages.nix"]},"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> |