aboutsummaryrefslogtreecommitdiff
path: root/posts
diff options
context:
space:
mode:
Diffstat (limited to 'posts')
-rw-r--r--posts/nixOS.md94
1 files changed, 94 insertions, 0 deletions
diff --git a/posts/nixOS.md b/posts/nixOS.md
new file mode 100644
index 0000000..7e91f93
--- /dev/null
+++ b/posts/nixOS.md
@@ -0,0 +1,94 @@
1I have been eyeing operating systems with functional package
2managers for a while now, aka, NixOS or Guix. Reproducible
3builds, declarative and rollback-able system configuration,
4system consistency, all sound pretty cool. I have been using
5NixOS for about a month now.
6
7### Installation
8
9I went with their minimal installation ISO. The installation
10was pretty smooth from start to end, no hitches there. The
11entire [manual](https://nixos.org/manual/nixos/stable/) is
12available offline, and is accessible during the
13installation. Very handy.
14
15### Setup
16
17The entire system is configured via
18`/etc/nixos/configuration.nix`. Wifi, `libinput` gestures,
19audio, locale settings, there are options for literally
20everything. You can declaratively write down the packages
21you want installed too. With fresh installs of most distros,
22I usually fumble with getting things like screen backlight
23and media keys to work. If I do manage to fix it, I can't
24carry it forward to future installations trivially. Getting
25all my hardware to work on NixOS is as easy as:
26
27```
28{
29 server.xserver.libinput.enable = true; # touchpad
30 programs.light.enable = true; # backlight
31 hardware.pulseaudio.enable = true; # audio
32 networking.wireless.enable = true; # wifi
33}
34```
35
36### Developing with Nix
37
38Nix makes it easy to enter environments that aren't affected
39by your system configuration using `nix-shell`.
40
41Builds may be generated by specifying a `default.nix` file,
42and running `nix-build`. Conventional package managers
43require you to specify a dependency list, but there is no
44guarantee that this list is complete. The package will build
45on your machine even if you forget a dependency. However,
46with Nix, packages are installed to `/nix/store`, and not
47global paths such as `/usr/bin/...`, if your project builds,
48it means you have included every last one.
49
50Issues on most my projects have been "unable to build
51because `libxcb` is missing", or "this version of `openssl`
52is too old". Tools like `cargo` and `pip` are poor package
53managers. While they *can* guarantee that Rust or Python
54dependencies are met, they make assumptions about the
55target system.
56
57For example, [this
58website](https://github.com/nerdypepper/site) is now built
59using Nix, anyone using Nix may simply, clone the repository
60and run `./generate.sh`, and it would *just work*, while
61keeping your global namespace clean™:
62
63```bash
64#! /usr/bin/env nix-shell
65#! nix-shell -i bash -p eva pandoc esh
66
67# some bash magic ;)
68```
69
70Dependencies are included with the `-p` flag, the shell
71script is executed with an interpreter, specified with the
72`-i` flag.
73
74### Impressions
75
76NixOS is by no means, simple. As a newcomer, using Nix was
77not easy, heck, I had to learn a purely functional, lazy
78language to just build programs. There is a lot to be
79desired on the tooling front as well. A well fleshed out LSP
80plugin would be nice ([rnix-lsp looks
81promising](https://github.com/nix-community/rnix-lsp)).
82
83Being able to rollback changes at a system level is cool.
84Package broke something? Just `nixos-rebuild switch
85--rollback`! Deleted `nix` by mistake? Find the binary in
86`/nix/store` and rollback! You aren't punished for not
87thinking twice.
88
89I don't see myself switching to anything else in the near
90future, NixOS does a lot of things right. If I ever need to
91reinstall NixOS, I can generate an [image of my current
92system](https://github.com/nix-community/nixos-generators).
93
94[![](https://u.peppe.rs/6m.png)](https://u.peppe.rs/6m.png)