NixOS

Created: by Pradeep Gowda Updated: Oct 26, 2023 Tagged: devops · nixos

Why NixOS

Via this HN Comment Maintaining your system configuration is an exercise in software development like any other - if you lack rigor or discipline, your codebase will become painful to work with. Nothing is ever one shell incantation away - it has to be carefully architected into the existing system.

That being said, once you get the hang of things, you reap amazing benefits:

  • You can clone your system to any machine, and immediately have an identical environment
  • You can share system configurations as code (declare the means for hosting a website in its repository, for example)
  • You can use a fully-fledged programming language to configure any part of your system
  • You can make use of an extensive ecosystem of easily composable, prebuilt NixOS modules
  • You can seamlessly integrate with Nix, allowing for ephemeral development environments and shells with packages, eliminating much of the need for imperative package management
  • Everything in a Nix-based system must be derived strictly from (lockfiled) inputs, making the reproducibility guarantees incredibly strong (barring any network errors or resources being taken down)
  • The declarative nature of anything Nix-based means that every change is documented - your system never shifts from the source of truth, compared to other distros where discipline is required to maintain reproducibility
  • Nix is so robust that you could even nuke your filesystems on every log out, if you’d like

Quick Reference


nix-env -iA nixpkgs.octave # to install octave
nix-env -e octave # to uninstlal octave
nix-env --delete generations # to delete old generations
# See [GC](https://nixos.org/manual/nix/stable/package-management/garbage-collection.html)
nix-storage --gc # for collecting garbage and actually removing files from HDD

Nix Language

Nix Flakes

Tutorials

NixOps

Nix land

via domenkozar:

Nix + Rust

Articles

Blogs

  • Computing - Shen’s Essays has many nixos articles including how to setup home manager, sway, wayland, FDE, latex on linux friendly laptop like Purism Librem.

Running log

2022-11-27 MyNixOS (selfnote: account using github.) - Build and share reproducible software environments with Nix and NixOS.

2022-10-24 Blog posts on Nix at ianthehenry.com; and Using Nix on macOS

2018-06-05 - Testing Nix Packages in Docker - https://cachix.org/ tied to my github account. - Integration woes with docker containers and NixOS - NixOS on prgmr and Failing to Learn Nix | push.cx .. and comments

2019-02-24 Static Nix: a command-line swiss army knife.. looks promising to use even on systems where creating -nix is not an option. Can run nix as an unprivileged user.

2019-10-14 bauer: an Emacs+Nix IDE

2019-11-11 Package a Django websiteacelpb/acelpb: Configuration for acelpb.com 2019-11-11 Nix for Python developers | Asko Soukka

2019-11-26 Nix recipes for Haskellers — Sridhar Ratnakumar

2020-02-29 Edit /etc/configuration.nix to add default packages. Run nixos-rebuild switch to update the system to match the configuration.

cron is not installed by default (because nix uses systemd timersand users not allowed to have crontab by default too! quelle surprise. To do that you have to edit the /etc/configuration.nix file do any thing.

2023-03-06 Nix-powered development with OCaml - Dimitrije’s Website

2023-09-25 Fast, Declarative, Reproducible, and Composable Developer Environments - devenv

2024-03-28 Flakes aren’t real and cannot hurt you: a guide to using Nix flakes the non-flake way - jade’s www site