Nix has changed the way I work, it has changed the way I setup developer environments and how I manage my dotfiles. New workstations are up and running in an hour or less.
This is a somewhat contrived comparison of nix and flatpack furniture assembly, getting from tools and material to a finished product. A reproducible product anyone can deterministically replicate with the right instructions and a set list of materials and tools.
The Nix Language And Standard Library: Your Toolbox
The language is like the toolbox you use to assemble your furniture, it contains all the tools you need: screwdrivers, drills, saws, sanders, measuring tapes etc.*
With these tools you can build any piece of furniture, whether a simple chair or elaborate shelving unit. You can make it as simple or complex as you need it to be.
However, the tools won't show you what to build or even ensure you have all the necessary materials - they are just the means to craft and assemble.
Derivations: Assembly Instructions
Derivations are like step-by-step assembly instructions that come with flatpack furniture. They describe exactly how to fit individual pieces together and in what order.
You can use the instructions to assemble provided components or show you how parts need to be constructed to slot together in case you want to design your own pieces that integrate with an IKEA product.
Normal Nix Files: A Box of Random Parts
A normal nix file is like that box of random parts in the corner of your workshop. You might have some screws from a desk, an extra shelf from a cabinet and some instructions on how to assemble a chair.
You can use the pieces to make something new, but you're going to have a tough time finding the parts that fit together. You end up with a new set of step-by-step instructions, but you cannot specify exactly what versions of the parts you used.
Flakes: Flatpacks Ready for Assembly
Flakes are like new flatpacks, everything is neatly packaged and for a specific purpose.
Each individual flatpack includes step by step assembly instructions (flake outputs like packages, apps or system configurations). All the required parts are provided (flake inputs like dependencies and/or external components).
With flakes you can also create custom additions - like a unique shelf or accessory - that integrates seamlessly with the flatpack, ensuring it works with the rest of the design.
Flakes make the process reproducible and shareable. If someone else picks up the same flatpack, they can assemble it exactly as intended.
Like each flatpack has a list of components, flakes have a lock file. They are like the detailed list of parts (and their versions) included with your flatpack. It ensures every screw, panel and bracket within the flatpack comes from the same sources as when the kit was first packed. You are (almost) guaranteed to get the same result after every assembly as long as the parts are sourced the same way with exactly the same version.
Building Beyond the Basics
With IKEA, you're not limited to the standard designs - you can create and combine to achieve custom solutions. You can use parts from multiple flatpacks to create a modular system. You can design and build your own custom cabinet door that fits perfectly into an existing design, fitting with IKEA's standard dimensions.
In nix, flakes work the same way: they let you combine standard packages and configurations with your own creations, all while keeping things modular and organised.
* Ok, ok, I know all you need for a flatpack is literally one screwdriver and the provided hex-key...