← Back to context

Comment by jmholla

4 days ago

> I've turned to flakes to specifically solve some problems, and flaked solved them. To this day, flakes are still the only way to solve them.

Can you share some examples of such problems?

With flakes I can get other people to run exactly the stuff I packaged with one command e.g. `nix run github:...` which can also be a reference to specific commit BTW.

At this point I don't even quite remember what would be the sane alternative without flakes but I am happy to discuss...

I can say what I use flakes for at work:

I have a repository with system configurations for some CI infrastructure: a build server, a test runner.

The test runner can either be generated as an SD-card image using nixos-generators or live-updated using a remote `nixos-rebuild switch`. The OS configuration contains stuff about purposing specific motherboard GPIO pins.

Both systems depend on custom software not in nixpkgs; these are just hosted in private git and have a flake that mainly provide a devShell, but also provide a cross-compiled binary.

Flakes handle all of that in a predictable way: OS images, cross-compiled binaries, devShells, cross-repo linking, convenient hash-pinning.

1) Channels are hard to maintain (that's why overlays were introduced...)

2) Overlays only solve issue of adding your own packages to an existing channel

3) System channels and user channels are two different things.

4) Many times I've updated my home-manager profile and forgot to update system profile and it borked due to channels being out of sync (user error, but flakes remove that foot gun)

5) Very easy to have portable dev-env. If a system has nix installed, just typing `nix develop` in my repo would put you in the exactly same dev environment as me. In most cases it would byte for byte identical. I'm not going to tell you to install 100 of dependencies, not going to bother you with what application is written in, all you have to do to build it locally is to type `nix build .#`. I'm not even going to bother you how to run test because `nix check` will run them.

6) Flakes provide some schema, you know here nixos or home-manager modules would be.

7) Flakes are easy to compose together

8) I can have identical env on CI, production and my local machine without any extra overhead - flake.lock takes care of this.

All of this is extremely predictable: I got a new laptop, using nix-anywhere I've installed nixos on it, that had pretty much identical look and feel of my desktop. It all boils down to - channels suck and hard to use.