diff options
author | Akshay <[email protected]> | 2023-02-12 06:43:49 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2023-02-12 06:43:49 +0000 |
commit | 366df8852f503523cc4f9046d82ba9a99dd51d7f (patch) | |
tree | 635884dd5700cdc2a22a8885031aa67816bbe1b0 /docs/posts/nixOS | |
parent | 57a1fc656e05e1fcf07e4cff3dc988c6b5c2bc59 (diff) |
new art: lapse
Diffstat (limited to 'docs/posts/nixOS')
-rw-r--r-- | docs/posts/nixOS/index.html | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/docs/posts/nixOS/index.html b/docs/posts/nixOS/index.html index 75be58f..9650bdd 100644 --- a/docs/posts/nixOS/index.html +++ b/docs/posts/nixOS/index.html | |||
@@ -33,7 +33,7 @@ | |||
33 | <span class="stats-unit">cm</span> | 33 | <span class="stats-unit">cm</span> |
34 |   | 34 |   |
35 | <span class="stats-number"> | 35 | <span class="stats-number"> |
36 | 3.3 | 36 | 3.4 |
37 | </span> | 37 | </span> |
38 | <span class="stats-unit">min</span> | 38 | <span class="stats-unit">min</span> |
39 | </div> | 39 | </div> |
@@ -42,11 +42,24 @@ | |||
42 | NixOS | 42 | NixOS |
43 | </h1> | 43 | </h1> |
44 | <div class="post-text"> | 44 | <div class="post-text"> |
45 | <p>I have been eyeing operating systems with functional package managers for a while now, aka, NixOS or Guix. Reproducible builds, declarative and rollback-able system configuration, system consistency, all sound pretty cool. I have been using NixOS for about a month now.</p> | 45 | <p>I have been eyeing operating systems with functional package managers |
46 | for a while now, aka, NixOS or Guix. Reproducible builds, declarative | ||
47 | and rollback-able system configuration, system consistency, all sound | ||
48 | pretty cool. I have been using NixOS for about a month now.</p> | ||
46 | <h3 id="installation">Installation</h3> | 49 | <h3 id="installation">Installation</h3> |
47 | <p>I went with their minimal installation ISO. The installation was pretty smooth from start to end, no hitches there. The entire <a href="https://nixos.org/manual/nixos/stable/">manual</a> is available offline, and is accessible during the installation. Very handy.</p> | 50 | <p>I went with their minimal installation ISO. The installation was |
51 | pretty smooth from start to end, no hitches there. The entire <a | ||
52 | href="https://nixos.org/manual/nixos/stable/">manual</a> is available | ||
53 | offline, and is accessible during the installation. Very handy.</p> | ||
48 | <h3 id="setup">Setup</h3> | 54 | <h3 id="setup">Setup</h3> |
49 | <p>The entire system is configured via <code>/etc/nixos/configuration.nix</code>. Wifi, <code>libinput</code> gestures, audio, locale settings, there are options for literally everything. You can declaratively write down the packages you want installed too. With fresh installs of most distros, I usually fumble with getting things like screen backlight and media keys to work. If I do manage to fix it, I can’t carry it forward to future installations trivially. Getting all my hardware to work on NixOS is as easy as:</p> | 55 | <p>The entire system is configured via |
56 | <code>/etc/nixos/configuration.nix</code>. Wifi, <code>libinput</code> | ||
57 | gestures, audio, locale settings, there are options for literally | ||
58 | everything. You can declaratively write down the packages you want | ||
59 | installed too. With fresh installs of most distros, I usually fumble | ||
60 | with getting things like screen backlight and media keys to work. If I | ||
61 | do manage to fix it, I can’t carry it forward to future installations | ||
62 | trivially. Getting all my hardware to work on NixOS is as easy as:</p> | ||
50 | <pre><code>{ | 63 | <pre><code>{ |
51 | server.xserver.libinput.enable = true; # touchpad | 64 | server.xserver.libinput.enable = true; # touchpad |
52 | programs.light.enable = true; # backlight | 65 | programs.light.enable = true; # backlight |
@@ -54,20 +67,53 @@ | |||
54 | networking.wireless.enable = true; # wifi | 67 | networking.wireless.enable = true; # wifi |
55 | }</code></pre> | 68 | }</code></pre> |
56 | <h3 id="developing-with-nix">Developing with Nix</h3> | 69 | <h3 id="developing-with-nix">Developing with Nix</h3> |
57 | <p>Nix makes it easy to enter environments that aren’t affected by your system configuration using <code>nix-shell</code>.</p> | 70 | <p>Nix makes it easy to enter environments that aren’t affected by your |
58 | <p>Builds may be generated by specifying a <code>default.nix</code> file, and running <code>nix-build</code>. Conventional package managers require you to specify a dependency list, but there is no guarantee that this list is complete. The package will build on your machine even if you forget a dependency. However, with Nix, packages are installed to <code>/nix/store</code>, and not global paths such as <code>/usr/bin/...</code>, if your project builds, it means you have included every last one.</p> | 71 | system configuration using <code>nix-shell</code>.</p> |
59 | <p>Issues on most my projects have been “unable to build because <code>libxcb</code> is missing”, or “this version of <code>openssl</code> is too old”. Tools like <code>cargo</code> and <code>pip</code> are poor package managers. While they <em>can</em> guarantee that Rust or Python dependencies are met, they make assumptions about the target system.</p> | 72 | <p>Builds may be generated by specifying a <code>default.nix</code> |
60 | <p>For example, <a href="https://github.com/nerdypepper/site">this website</a> is now built using Nix, anyone using Nix may simply, clone the repository and run <code>./generate.sh</code>, and it would <em>just work</em>, while keeping your global namespace clean™:</p> | 73 | file, and running <code>nix-build</code>. Conventional package managers |
61 | <div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">#! /usr/bin/env nix-shell</span></span> | 74 | require you to specify a dependency list, but there is no guarantee that |
75 | this list is complete. The package will build on your machine even if | ||
76 | you forget a dependency. However, with Nix, packages are installed to | ||
77 | <code>/nix/store</code>, and not global paths such as | ||
78 | <code>/usr/bin/...</code>, if your project builds, it means you have | ||
79 | included every last one.</p> | ||
80 | <p>Issues on most my projects have been “unable to build because | ||
81 | <code>libxcb</code> is missing”, or “this version of | ||
82 | <code>openssl</code> is too old”. Tools like <code>cargo</code> and | ||
83 | <code>pip</code> are poor package managers. While they <em>can</em> | ||
84 | guarantee that Rust or Python dependencies are met, they make | ||
85 | assumptions about the target system.</p> | ||
86 | <p>For example, <a href="https://github.com/nerdypepper/site">this | ||
87 | website</a> is now built using Nix, anyone using Nix may simply, clone | ||
88 | the repository and run <code>./generate.sh</code>, and it would <em>just | ||
89 | work</em>, while keeping your global namespace clean™:</p> | ||
90 | <div class="sourceCode" id="cb2"><pre | ||
91 | class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co">#! /usr/bin/env nix-shell</span></span> | ||
62 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co">#! nix-shell -i bash -p eva pandoc esh</span></span> | 92 | <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="co">#! nix-shell -i bash -p eva pandoc esh</span></span> |
63 | <span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span> | 93 | <span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span> |
64 | <span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># some bash magic ;)</span></span></code></pre></div> | 94 | <span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># some bash magic ;)</span></span></code></pre></div> |
65 | <p>Dependencies are included with the <code>-p</code> flag, the shell script is executed with an interpreter, specified with the <code>-i</code> flag.</p> | 95 | <p>Dependencies are included with the <code>-p</code> flag, the shell |
96 | script is executed with an interpreter, specified with the | ||
97 | <code>-i</code> flag.</p> | ||
66 | <h3 id="impressions">Impressions</h3> | 98 | <h3 id="impressions">Impressions</h3> |
67 | <p>NixOS is by no means, simple. As a newcomer, using Nix was not easy, heck, I had to learn a purely functional, lazy language to just build programs. There is a lot to be desired on the tooling front as well. A well fleshed out LSP plugin would be nice (<a href="https://github.com/nix-community/rnix-lsp">rnix-lsp looks promising</a>).</p> | 99 | <p>NixOS is by no means, simple. As a newcomer, using Nix was not easy, |
68 | <p>Being able to rollback changes at a system level is cool. Package broke something? Just <code>nixos-rebuild switch --rollback</code>! Deleted <code>nix</code> by mistake? Find the binary in <code>/nix/store</code> and rollback! You aren’t punished for not thinking twice.</p> | 100 | heck, I had to learn a purely functional, lazy language to just build |
69 | <p>I don’t see myself switching to anything else in the near future, NixOS does a lot of things right. If I ever need to reinstall NixOS, I can generate an <a href="https://github.com/nix-community/nixos-generators">image of my current system</a>.</p> | 101 | programs. There is a lot to be desired on the tooling front as well. A |
70 | <p><a href="https://u.peppe.rs/6m.png"><img src="https://u.peppe.rs/6m.png" /></a></p> | 102 | well fleshed out LSP plugin would be nice (<a |
103 | href="https://github.com/nix-community/rnix-lsp">rnix-lsp looks | ||
104 | promising</a>).</p> | ||
105 | <p>Being able to rollback changes at a system level is cool. Package | ||
106 | broke something? Just <code>nixos-rebuild switch --rollback</code>! | ||
107 | Deleted <code>nix</code> by mistake? Find the binary in | ||
108 | <code>/nix/store</code> and rollback! You aren’t punished for not | ||
109 | thinking twice.</p> | ||
110 | <p>I don’t see myself switching to anything else in the near future, | ||
111 | NixOS does a lot of things right. If I ever need to reinstall NixOS, I | ||
112 | can generate an <a | ||
113 | href="https://github.com/nix-community/nixos-generators">image of my | ||
114 | current system</a>.</p> | ||
115 | <p><a href="https://u.peppe.rs/6m.png"><img | ||
116 | src="https://u.peppe.rs/6m.png" /></a></p> | ||
71 | 117 | ||
72 | </div> | 118 | </div> |
73 | 119 | ||