Learn Nix (Using This Repo)
Nix is both a package manager and a language for describing builds, environments, and system configuration. This repo is useful for learning it because it is not just a machine config repo. It shows how one pinned package set can become user environments, host configs, reusable modules, package overlays, and custom tools.
Quick Vocabulary
nixpkgs: the large upstream collection of packages and helper functions that most Nix projects build on.pin: an exact revision of an upstream input, used so builds stay reproducible.overlay: a function that extends or changes the package set.packageorderivation: a build recipe and its resulting output.module: a reusable configuration fragment for a system or user environment.flake: a standard way to declare inputs and expose outputs such as packages, dev shells, and machine configs.
Three Useful Distinctions
- A package answers, "how do I build or install this software?"
- A module answers, "how should this software or subsystem be configured?"
- A host answers, "what does this specific machine get?"
Docs-First Reading Path
If you want the concepts before the code, read these first:
- Architecture, for the shared package-set model.
- Home Manager, for the user-environment layer.
- Packages, for build recipes and package exposure.
- Case Study:
poglets, for one complete package -> module -> host walkthrough. - Tooling, for the repo-specific abstractions.
- Hosts and Modules, for machine-level composition.
What This Repo Teaches Well
- Importing a pinned
nixpkgsonce, then extending it with overlays. - Exposing multiple flake outputs from one shared package set.
- Separating user config, machine config, reusable modules, and package recipes.
- Turning Nix code into higher-level tooling like
pog,hex, andsnowball.
Read In This Order
Once the docs-level mental model is clear, trace the source like this:
- Pinned base
flake.nixflake.lockdefault.nix
- Overlay assembly
overlays.nixmods/_pkgs.nixmods/final.nix
- Daily user entry point
home.nixmods/hms.nix
- Machine layer
hosts/common.nixhosts/common_darwin.nixhosts/<name>/configuration.nix
- Reusable system pieces
hosts/modules/*
- Repo-specific tooling
mods/pog/*examples/hex/README.mdmods/snowball.nix
Mental Model
Think of the repo in five layers:
flake.nixdefines outputs.default.niximports the pinned nixpkgs input and injects shared inputs likepog,hex, anduv2nix.overlays.nixcomposes local overlays frommods/*.pkgs/*,hosts/*, andhome.nixconsume that overlayed package set for different jobs.mods/pog/*,mods/hms.nix,scripts.nix, andmods/snowball.nixturn the package set into daily tooling.
What To Skip At First
- Generated reference indexes, until you want an exact filename or path.
- CI and automation details, unless you are studying how the repo is validated.
- Secrets management, unless you are following host deployment and operations.
Suggested Exercises
- Run
nix flake showand identify one host output, one package output, and one script output. - Read Architecture, then trace one attribute from
default.nixto a concrete use site. - Build one host and one package from Daily Workflows.
- Read Case Study:
poglets, then compare that pattern to another service or package. - Read Tooling, then trace either
pog,hex, orsnowballend to end.