aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/nixOS/index.html
blob: 3e012f8a46bbe9e6544f26ab6dc77b329be426af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="/style.css">
    <link rel="stylesheet" href="/syntax.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1">
    <meta content="#ffffff" name="theme-color">
    <meta name="HandheldFriendly" content="true">
    <meta property="og:title" content="NixOS">
    <meta property="og:type" content="website">
    <meta property="og:description" content="a static site {for, by, about} me ">
    <meta property="og:url" content="https://peppe.rs">
    <link rel="icon" type="image/x-icon" href="/favicon.png">
    <title>NixOS · peppe.rs</title>
    <body>
      <div class="posts">
        <div class="post">
          <a href="/" class="post-end-link">Home</a>
          <span>/</span>
          <a href="/posts" class="post-end-link">Posts</a>
          <span>/</span>
          <a class="post-end-link">NixOS</a>
          <a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/nixOS.md
">View Raw</a>
          <div class="separator"></div>
          <div class="date">
            01/09 — 2020
            <div class="stats">
              <span class="stats-number">
                37.56
              </span>
              <span class="stats-unit">cm</span>
              &nbsp
              <span class="stats-number">
                3.3
              </span>
              <span class="stats-unit">min</span>
            </div>
          </div>
          <h1>
            NixOS
          </h1>
          <div class="post-text">
            <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>
<h3 id="installation">Installation</h3>
<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>
<h3 id="setup">Setup</h3>
<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>
<pre><code>{
    server.xserver.libinput.enable = true;  # touchpad
    programs.light.enable = true;           # backlight
    hardware.pulseaudio.enable = true;      # audio
    networking.wireless.enable = true;      # wifi
}</code></pre>
<h3 id="developing-with-nix">Developing with Nix</h3>
<p>Nix makes it easy to enter environments that aren’t affected by your system configuration using <code>nix-shell</code>.</p>
<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>
<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>
<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>
<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true"></a><span class="co">#! /usr/bin/env nix-shell</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true"></a><span class="co">#! nix-shell -i bash -p eva pandoc esh</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true"></a><span class="co"># some bash magic ;)</span></span></code></pre></div>
<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>
<h3 id="impressions">Impressions</h3>
<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>
<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>
<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>
<p><a href="https://u.peppe.rs/6m.png"><img src="https://u.peppe.rs/6m.png" /></a></p>

          </div>
          
    <div class="intro">
        Hi. 
        <div class="hot-links">
            <a href="https://peppe.rs/index.xml" class="feed-button">Subscribe</a>
            <a href="https://liberapay.com/nerdypepper/donate" class="donate-button">Donate</a>
        </div>
        <p>I'm Akshay, I go by nerd or nerdypepper on the internet.</p>
        <p>
        I am a compsci undergrad, Rust programmer and an enthusiastic Vimmer.
        I write <a href="https://git.peppe.rs">open-source stuff</a> to pass time. 
        I also design fonts: 
        <a href="https://git.peppe.rs/fonts/scientifica">scientifica</a>, 
        <a href="https://git.peppe.rs/fonts/curie">curie</a>.
        </p>
        <p>Send me a mail at [email protected] or a message at [email protected].</p>
    </div>
    
          <a href="/" class="post-end-link">Home</a>
          <span>/</span>
          <a href="/posts" class="post-end-link">Posts</a>
          <span>/</span>
          <a class="post-end-link">NixOS</a>
          <a class="stats post-end-link" href="https://git.peppe.rs/web/site/plain/posts/nixOS.md
">View Raw</a>
        </div>
      </div>
    </body>
</html>