all repos — gemini-redirect @ 4e76ffb372acbefd1eed19ac74caf7f564084240

blog/installing_nixos/index.html (view raw)

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<meta charset="utf-8" />
 5<meta name="viewport" content="width=device-width, initial-scale=1" />
 6<title>Installing NixOS</title>
 7<link rel="stylesheet" href="../css/style.css">
 8</head>
 9<body>
10<main>
11<h1 class="title" id="installing_nixos"><a class="anchor" href="#installing_nixos">¶</a>Installing NixOS</h1>
12<div class="date-created-modified">Created 2017-05-13<br>
13Modified 2019-02-16</div>
14<h2 id="update"><a class="anchor" href="#update">¶</a>Update</h2>
15<p><em>Please see <a href="../installing_nixos_2/index.html">my followup post with NixOS</a> for a far better experience with it</em></p>
16<hr />
17<p>Today I decided to install <a href="http://nixos.org/">NixOS</a> as a recommendation, a purely functional Linux distribution, since <a href="https://xubuntu.org/">Xubuntu</a> kept crashing. Here's my journey, and how I managed to install it from a terminal for the first time in my life. Steps aren't hard, but they may not seem obvious at first.</p>
18<ul>
19<li>
20<p>Grab the Live CD, burn it on a USB stick and boot. I recommend using <a href="https://etcher.io/">Etcher</a>.</p>
21</li>
22<li>
23<p>Type <code>systemctl start display-manager</code> and wait.<sup class="footnote-reference" id="r.1"><a href="#f.1">1</a></sup></p>
24</li>
25<li>
26<p>Open both the manual and the <code>konsole</code>.</p>
27</li>
28<li>
29<p>Connect to the network using the GUI.</p>
30</li>
31<li>
32<p>Create the disk partitions by using <code>fdisk</code>.</p>
33<p>You can list them with <code>fdisk -l</code>, modify a certain drive with <code>fdisk /dev/sdX</code> (for instance, <code>/dev/sda</code>) and follow the instructions.</p>
34<p>To create the file system, use <code>mkfs.ext4 -L &lt;label&gt; /dev/sdXY</code> and swap with <code>mkswap -L &lt;label&gt; /dev/sdXY</code>.</p>
35<p>The EFI partition should be done with <code>mkfs.vfat</code>.</p>
36</li>
37<li>
38<p>Mount the target to <code>/mnt</code> e.g. if the label was <code>nixos</code>, <code>mount /dev/disk/by-label/nixos /mnt</code></p>
39</li>
40<li>
41<p><code>mkdir /mnt/boot</code> and then mount your EFI partition to it.</p>
42</li>
43<li>
44<p>Generate a configuration template with <code>nixos-generate-config --root /mnt</code>, and modify it with <code>nano /etc/nixos/configuration.nix</code>.</p>
45</li>
46<li>
47<p>While modifying the configuration, make sure to add <code>boot.loader.grub.device = &quot;/dev/sda&quot;</code></p>
48</li>
49<li>
50<p>More useful configuration things are:</p>
51<ul>
52<li>Uncomment the whole <code>i18n</code> block.</li>
53<li>Add some essential packages like <code>environment.systemPackages = with pkgs; [wget git firefox pulseaudio networkmanagerapplet];</code>.</li>
54<li>If you want to use XFCE, add <code>services.xserver.desktopManager.xfce.enable = true;</code>, otherwise, you don't need <code>networkmanagerapplet</code> either. Make sure to add <code>networking.networkmanager.enable = true;</code> too.</li>
55<li>Define some user for yourself (modify <code>guest</code> name) and use a UID greater than 1000. Also, add yourself to <code>extraGroups = [&quot;wheel&quot; &quot;networkmanager&quot;];</code> (the first to be able to <code>sudo</code>, the second to use network related things).</li>
56</ul>
57</li>
58<li>
59<p>Run <code>nixos-install</code>. If you ever modify that file again, to add more packages for instance (this is how they're installed), run <code>nixos-rebuild switch</code> (or use <code>test</code> to test but don't boot to it, or <code>boot</code> not to switch but to use on next boot.</p>
60</li>
61<li>
62<p><code>reboot</code>.</p>
63</li>
64<li>
65<p>Login as <code>root</code>, and set a password for your user with <code>passwd &lt;user&gt;</code>. Done!</p>
66</li>
67</ul>
68<p>I enjoyed the process of installing it, and it's really cool that it has versioning and is so clean to keep track of which packages you install. But not being able to run arbitrary binaries by default is something very limitting in my opinion, though they've done a good job.</p>
69<p>I'm now back to Xubuntu, with a fresh install.</p>
70<h2 id="update_2"><a class="anchor" href="#update_2">¶</a>Update</h2>
71<p>It is not true that &quot;they don't allow running arbitrary binaries by default&quot;, as pointed out in their <a href="https://nixos.org/nixpkgs/manual/#sec-fhs-environments">manual, buildFHSUserEnv</a>:</p>
72<blockquote>
73<p><code>buildFHSUserEnv</code> provides a way to build and run FHS-compatible lightweight sandboxes. It creates an isolated root with bound <code>/nix/store</code>, so its footprint in terms of disk space needed is quite small. This allows one to run software which is hard or unfeasible to patch for NixOS -- 3rd-party source trees with FHS assumptions, games distributed as tarballs, software with integrity checking and/or external self-updated binaries. It uses Linux namespaces feature to create temporary lightweight environments which are destroyed after all child processes exit, without root user rights requirement.</p>
74</blockquote>
75<p>Thanks to <a href="https://github.com/bb010g">@bb010g</a> for pointing this out.</p>
76<h2 id="notes"><a class="anchor" href="#notes">¶</a>Notes</h2>
77<p class="footnote" id="f.1"><sup>1</sup> The keyboard mapping is a bit strange. On my Spanish keyboard, the keys were as follows: <a href="#r.1">↩</a></p>
78<table><thead><tr><th>Keyboard</th><th>Maps to</th><th>Shift</th></tr></thead><tbody>
79<tr><td>'</td><td>-</td><td>_</td></tr>
80<tr><td>´</td><td>'</td><td>&quot;</td></tr>
81<tr><td>`</td><td>[</td><td></td></tr>
82<tr><td>+</td><td>]</td><td></td></tr>
83<tr><td>¡</td><td>=</td><td></td></tr>
84<tr><td>-</td><td>/</td><td></td></tr>
85<tr><td>ñ</td><td>;</td><td></td></tr>
86</tbody></table>
87</main>
88</body>
89</html>
90