Nixos-flake-example: flakes justification + example nixos cfg w/ optional flake support

Hi,

I am finding myself answering a lot of the same questions about Flakes repeatedly.

I’ve created this repo to try and emphasize that flakes are mostly just syntax and a mechanism for localizing and locking inputs, in the pursuit of pure, hermetic builds. Further, it builds a system config, with and without flakes to prove that they produce the same output.

https://github.com/colemickens/nixos-flake-example, though “flake-essentials” might be a better name?

I think I should probably take it as a goal to move most of this information into the Flakes wiki page but (1) I can write Markdown twice as fast as wiki syntax, and (2) it is useful to have the repo+script in one place for demonstrative purposes. At the very least, the implicit use of flake.nix from a directory should be documented, it trips some folks up.

Please LMK if you think this is useful, have feedback, etc, or just open issues on that repo.

2 Likes

I do need a piece of advice.

When my inner nixos configuration wants to pull a package from an overlay, etc, how am I meant to, idiomatically get access to the other inputs in my flake?

For example, I think a number of us shove inputs into nixos specialArgs and then have access to it in module imports, but I know there is also builtins.getFlake. Advice?

The Nix manual on master is in markdown nowadays. Of course, this covers Nix only, and not the NixOS-specific attributes. Given https://github.com/NixOS/rfcs/pull/72 is accepted soon, the manuals in nixpkgs can be converted as and then there is a place for it there as well.

2 Likes