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
See MyNixOS site — home.sessionVariables - MyNixOS
Nix Language
- https://nix.dev/ — An opinionated guide for developers wanting to get things done using the Nix ecosystem.
- Nix explained from the ground up - YouTube
- Is there good explanation anywhere of the syntax of those files? I tried getting… | Hacker News
- Learn nix in Y Minutes
- A Gentle Introduction to the Nix Family
- Nix Language Primer | binary.phile
- Environments with Nix Shell - Learning Nix pt 1 - sam.today; there are 4 posts as of Oct 2022.
- Explainix — explain nix visually; Feb 2024.
Nix Flakes
Tutorials
- Learning Nix from the bottom up
- Matthew Croughan - What Nix Can Do - SCaLE20x - YouTube; Mar 2023. Nix REPL.
- Zero to Nix
- Learning Nix by Example: Building FFmpeg 4.0 - Nedtes
- shajra/example-nix: a way to develop software with Nix
- How I Start: Nix - Christine Dodrill; Mar 2020.
- Building 15-year-old software with Nix; Apr 2023. Builds GIMP and Blender from 2008.
- NixOS & Flakes Book | Home Page; Oct 2023.
- How I use Nix on macOS | Fatih’s Personal Blog; Feb 2024.
NixOps
Nix land
via domenkozar:
- binary cache service: http://cachix.org (2018)
- ci: http://hercules-ci.com (2019)
- documentation site: http://nix.dev (2020)
- deploy: http://app.cachix.org/deploy (2021)
Nix + Rust
Articles
- An unordered list of hidden gems inside NixOS
- Nix - Why Now by Alex Mackenzie. “Containers without Containers”. Nov 2022.
- Erase your darlings: immutable infrastructure for mutable systems - Graham Christensen
- The best presentation on Nix package manager by Arian Van Putten I’ve read; Aug 2018.
- Everything You Always Wanted To Know About Nix (But Were Afraid To Ask) — Youtube talk by Edward Amsden.
- Lightning Introduction to Nix for Developers - sulami’s blog; Nov 27, 2020.
- Nix, the PhD Thesis presentation by Philip Potter.
- You Are Most Likely Misusing Docker — you could be using Nix instead.
- What is Nix and Why you should try it!
- What Is Nix by shopify engineering; May 2020.
- Nix, the purely functional build system by Alexei Bornoine. This is a pretty good introduction to set up nix and do a “Hello world!” app build. Pay special attention to the case study of HSLuv, a website that is built and deployed entirely using Nix. What makes this a good example to study is that the website uses multiple, disparate software systems (JDK, Haxe, Node.js etc.,).
- NixOS: A lasting impression | Jeaye’s Blog Anders’ Blog - The NixOS Landscape - Nix, nixpkgs, NixOS — what the different words mean.
- Nix by example, Part 1: The Nix expression language — This is quite good; Oct 24 2019.
- Intro with python virtualenv/buildout examples.
- Nix Cookbook by Susan Potter.
- Control your packages with Nix created profiles! [Jan 2014]
- zalora has developed quite a nix packages and use it Production
- setting up development environments with nix is a good, hands-on intro.
- NixOS + Hydra + Nginx — setting up your own Hydra build server.
- Sander van der Burg’s blog: Setting up a Hydra build cluster for continuous integration and testing (part 1)
- Sander van der Burg’s blog: Setting up a Hydra build cluster for continuous integration and testing (part 2)
- NixOS and stateless deployment. good discussion on challenges with downgrade, packaging non-ELF binaries etc.,
- Nix adoption at Rhodecode [Aug 2015]
- A tour of nix — practice nix expressions in the browser [Nov 2015]
- Stack + Nix = portable reproducible builds [Dec 2015]
- Tinco.nl; discussion
- How to setup your own hydra server (video). Source code.
- Fully setting up a custom nix repository
- A historical perspective on Disnix
- nixfmt — Automatic code formatter for the Nix programming language.
- From Vagrant to NixOps - Mayflower Blog 2017
- NixOS Weekly
- nh2/nix-binary-cache-proxy: An NGINX caching proxy to serve the cache.nixos.org binary cache from your local network, ready-to-deploy with nixops
- Nix under the hood by Gabriel439 [Dec 2017].
- Deploy software easily and securely using nix-deploy [Dec 2017]. nixos configs to study:
- Corey O’connor
- NixOS 2.0 release lobste.rs discussion
- Docker Layers, Caching, and Nix - Graham Christensen
- NixOS for the Impatient talks about how to setup home-manager with easy example.
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 website — acelpb/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