mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
20 lines
13 KiB
HTML
20 lines
13 KiB
HTML
|
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Nix language</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 language</h1><section class="post-metadata"><span>Date: <!-- -->2021-06-30 13:30:19 +08:00</span><span>Date modified: <!-- -->2021-12-28 00:17:58 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/lang.nix#what-is-it-for" class="toc-link toc-link-h1">What is it for?</a></li><li class="toc-item toc-item-h1"><a href="/wiki/lang.nix#builtins" class="toc-link toc-link-h1">Builtins</a><ol class="toc-level toc-level-2"><li class="toc-item toc-item-h2"><a href="/wiki/lang.nix#imports" class="toc-link toc-link-h2">Imports</a></li></ol></li><li class="toc-item toc-item-h1"><a href="/wiki/lang.nix#standard-library" class="toc-link toc-link-h1">TODO Standard library</a></li></ol></nav><p>Nix can be aptly described as JSON but with functions.
|
||
|
While you can make Nix work with basic configurations, you need to know the details if you're creating packages.
|
||
|
</p><p>You can actively play with the language by running <code class="inline-code">nix repl</code>.
|
||
|
This is just a personal reference note, the recommended resource for learning the language is the beloved <a href="https://nixos.org/guides/nix-pills/">Nix pills</a>.
|
||
|
</p><h1 id="what-is-it-for">What is it for?</h1><ul><li><p>most importantly, writing packages, specifically <a href="/wiki/tools.nix.derivations">Nix derivations</a></p></li><li><p>mostly used for configuring <a href="https://nixos.org/manual/nixos/stable/">operating systems</a> and create servers quickly with its variety of services
|
||
|
</p></li><li><p>configuring <a href="/wiki/tools.nix">Nix package manager</a></p></li></ul><h1 id="builtins">Builtins</h1><ul><li><p><code class="inline-code">builtins.toString ./.</code> will print out the current directory.
|
||
|
</p></li><li><p><code class="inline-code">builtins.getFlake $PATH</code></p></li></ul><h2 id="imports">Imports</h2><ul><li><p>the <code class="inline-verbatim">import</code> builtin will simply import the Nix expression given a path.
|
||
|
</p></li><li><p>because of the functional paradigm, you'll often see the builtin used with the parameters in one go — e.g., <code class="inline-code">import <nixpkgs> { }</code> which will import nixpkgs from one of the module paths with the default attribute set.
|
||
|
</p></li></ul><h1 id="standard-library"><span class="todo-keyword TODO" id="standard-library">TODO</span> <!-- -->Standard library</h1><ul><li><p>nixpkgs has a standard library that comes with functions mitigating against the verbosity for packaging or simply convenience
|
||
|
</p></li><li><p></p></li></ul><section><h2>Backlinks</h2><ul><li><a href="/wiki/editor.neovim.lua-modules">Neovim Lua modules</a></li><li><a href="/wiki/packages.nix">Nix packages</a></li><li><a href="/wiki/tools.nix.derivations">Nix derivations</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-06-30 13:30:19 +08:00\"","date_modified":"\"2021-12-28 00:17:58 +08:00\"","language":"en","source":""},"title":"Nix language","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":"what-is-it-for"},"children":[{"type":"text","value":"What is it for?"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/lang.nix#what-is-it-for"},"children":[{"type":"text","value":"What is it for?"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"builtins"},"children":[{"type":"text","value":"Builtins"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/lang.nix#builtins"},"children":[{"type":"text","value":"Builtins"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"imports"},"children":[{"type":"text","value":"Imports"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/lang.nix#imports"},"children":[{"type":"text","value":"Imports"}]}]}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"standard-library"},"children":[{"type":"element","tagName":"span","properties":{"className":["todo-keyword","TODO"],"id":"standard-library"},"children":[{"type":"text","value":"TODO"}]},{"type":"text","value":" "},{"type":"text","value":"Standard library"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/lang.nix#standard-library"},"children":[{"type":"text","value":"TODO Standard library"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Nix can be aptly described as JSON but with functions.\nWhile you can make Nix work with basic configurations, you need to know the details if you're creating packages.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"You can actively play with the language by running "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"nix repl"}]},{"type":"text","value":".\nThis is just a personal reference note, the recommended resource for learning the language is the beloved "},{"type":"element","tagName":"a","properties":{"href":"https://nixos.org/guides/nix-pills/"},"children":[{"type":"text","value":"Nix pills"}]},{"type":"text","value":".\n"}]},{"type":"element","tagName":"h1","properties":{"id":"what-is-it-for"},"children":[{"type":"text","value":"What is it for?"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"most importantly, writing packages, specifically "},{"type":"element","tagName":"a","properties":{"href":"/tools.nix.derivations"},"children":[{"type":"text","value":"Nix derivations"}]}]}]},{"type":"element","tagName":"li","properties":{},"chil
|