From 67371be8272dd12683a0502ab4bbc3e3a92b2e1d Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sun, 15 Sep 2019 11:27:44 +0200 Subject: [PATCH 1/3] NixOS notes: Start --- _posts/2019-09-15-nixos-notes.md | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 _posts/2019-09-15-nixos-notes.md diff --git a/_posts/2019-09-15-nixos-notes.md b/_posts/2019-09-15-nixos-notes.md new file mode 100644 index 0000000..7030109 --- /dev/null +++ b/_posts/2019-09-15-nixos-notes.md @@ -0,0 +1,63 @@ +--- +title: NixOS notes +categories: +- linux +- nix +--- + +I think I've come to terms with the fact that +my (new-ish) job will continue to contain sysadmin work. +Maybe because I'm not too bad at ssh-ing into a Linux box +and messing with it long enough +to have a bunch of interdependent services working; +or maybe because I kinda want to be able to make sure my stuff runs correctly. +Thus, +I started looking into how to make this less error-prone. +I don't want to manually edit files, restart a thing and pray that it still runs. +I also don't want the current working state be an accidental result of pressing the right buttons +but instead of correct, reproducible configuration. +Ideally, I even want to have this documented in version control. + +On top of all that I also wanted to start using Linux on my desktop again +(after living Mac-only for a while), +and I'd really appreciate if I could take the advantages of this server provisioning setup with me. +So: I looked into NixOS. + +(There are a lot of considerations and trade-offs for and against other approaches +but this is not the post to discuss them.) + +# The idea + +The premise of NixOS is to have a declarative way of setting up your system. +You define what you want your system to be, +run `nixos-rebuild switch`, +and it will make sure your system will be as described. +In an ideal world that means you don't have to ever touch a config file +outside of `/etc/nixos`, +and that you whole machine's configuration can be easily put into a git repo. +(So you don't have to do steps like [these][arch-setup] manually!) + +[arch-setup]: https://github.com/mmozeiko/arch-setup + +# The Nix Language + +NixOS is a Linux distributions based on the `nix` package manager. +For maximum confusion, +the configuration language of the `nix` package manager is also called Nix. +But it's fine, +I just read the former as the suffix of "Unix" +and the latter as the German word for "nothing". +That makes everything much more clear. +(Oh and also the style of writing `nix` vs. Nix.) + +Nix is a domain-specific language. +This is a feature I very much appreciate +but that also needs some explaining. +The syntax may seem weird at first, +but it is designed to work well for configuring that state of a system in a concise way: +It allows expressing (and merging) nested properties, +writing paths or URLs as literals, +and has string interpolation without common footguns. +It also features control flow constructs, +curried functions, +and lazy evaluation. \ No newline at end of file From 022f897755ccf3bfc41f53175ad72075031c7986 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sat, 21 Mar 2020 21:58:21 +0100 Subject: [PATCH 2/3] Nix: Let's give this another go --- ...xos-notes.md => 2020-03-23-nixos-notes.md} | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) rename _posts/{2019-09-15-nixos-notes.md => 2020-03-23-nixos-notes.md} (79%) diff --git a/_posts/2019-09-15-nixos-notes.md b/_posts/2020-03-23-nixos-notes.md similarity index 79% rename from _posts/2019-09-15-nixos-notes.md rename to _posts/2020-03-23-nixos-notes.md index 7030109..709746f 100644 --- a/_posts/2019-09-15-nixos-notes.md +++ b/_posts/2020-03-23-nixos-notes.md @@ -6,27 +6,28 @@ categories: --- I think I've come to terms with the fact that -my (new-ish) job will continue to contain sysadmin work. +my job will always contain sysadmin work. Maybe because I'm not too bad at ssh-ing into a Linux box and messing with it long enough to have a bunch of interdependent services working; or maybe because I kinda want to be able to make sure my stuff runs correctly. +(And I have own my personal and very specific definition of "correctly".) Thus, I started looking into how to make this less error-prone. I don't want to manually edit files, restart a thing and pray that it still runs. -I also don't want the current working state be an accidental result of pressing the right buttons -but instead of correct, reproducible configuration. +I also don't want the current working state to be an accidental result of pressing the right buttons +instead of a correct, reproducible configuration. Ideally, I even want to have this documented in version control. On top of all that I also wanted to start using Linux on my desktop again (after living Mac-only for a while), and I'd really appreciate if I could take the advantages of this server provisioning setup with me. -So: I looked into NixOS. +Long story short: I looked into NixOS. (There are a lot of considerations and trade-offs for and against other approaches but this is not the post to discuss them.) -# The idea +## The idea The premise of NixOS is to have a declarative way of setting up your system. You define what you want your system to be, @@ -39,7 +40,7 @@ and that you whole machine's configuration can be easily put into a git repo. [arch-setup]: https://github.com/mmozeiko/arch-setup -# The Nix Language +## The Nix Language NixOS is a Linux distributions based on the `nix` package manager. For maximum confusion, @@ -60,4 +61,16 @@ writing paths or URLs as literals, and has string interpolation without common footguns. It also features control flow constructs, curried functions, -and lazy evaluation. \ No newline at end of file +and lazy evaluation. + +## The package manager and its store + +## Constructing environments + +### Aside: Package-specific FSH environments + +## NixOS on the desktop + +### Limits of my current setup + +### Developing software on NixOS From 71a963b8a3e9d263ae602a16b7d39c8fde30d8f6 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sun, 22 Mar 2020 20:12:02 +0100 Subject: [PATCH 3/3] nix scribbles --- _posts/2020-03-23-nixos-notes.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/_posts/2020-03-23-nixos-notes.md b/_posts/2020-03-23-nixos-notes.md index 709746f..d3cb764 100644 --- a/_posts/2020-03-23-nixos-notes.md +++ b/_posts/2020-03-23-nixos-notes.md @@ -63,8 +63,25 @@ It also features control flow constructs, curried functions, and lazy evaluation. +Most of the `nix`-related tooling works by evaluating Nix expressions. + ## The package manager and its store +The `nix` package manager has a pretty unique design. +First off, packages are defined as a Nix expression. +Evaluating it returns the full dependency tree, +including all build- and runtime dependencies. +`nix` puts the output (a directory with files) +of each built package into its store, +identified by the hash of all inputs and the package name. + +To be able to execute a program from a package, +`nix` creates symlinks to add it (user or system) profiles. +If necessary, the package also includes wrappers to load the necessary dependencies +using their full paths. +This means that adding packages is pretty much an atomic operation +and doesn't change any system files. + ## Constructing environments ### Aside: Package-specific FSH environments