6 ms·
That's kind of an unfair comparison. The flake you linked: 1. Defines a Go binary (i.e., how to build it) 2. Defines a Docker image that uses said Go binary a
by Cyph0n 3y ago
That's kind of an unfair comparison. The flake you linked:
1. Defines a Go binary (i.e., how to build it)
2. Defines a Docker image that uses said Go binary as an entry point
3. Defines a NixOS module that creates a systemd service that runs the Go binary (only relevant on NixOS)
4. Defines a NixOS test for the module that ensures that the NixOS module actually creates a systemd service that runs the Go binary as expected. The NixOS test framework is actually quite impressive - tests run in a QEMU VM that also runs NixOS :)
Note that only (1) and (2) are relevant to the linked article (+ some of the surrounding boilerplate).
- hamandcheese 3y agoI agree that it's not a fair comparison, but I will add that this is a big barrier to newcomers. Everyone experienced with nix builds their own ivory tower of a nix flake (myself included), so it's hard to find actually good examples of how to do basic things without wading through a bunch of other bullshit.
- Cyph0n 3y agoI'm a beginner myself and have been trying my best to keep things simple. But I do agree that the complexity creep is quite tempting with Nix. Not sure why though..
- hamandcheese 3y agoI think nix has a fair amount of gravity - once you've started, assuming like it, you will quickly want to use it for everything. I don't think most people's flakes are more complex than the alternative (which would be, I don't know, a bunch of different script, maybe some ansible playbooks?) but it is a bit daunting when all that complexity is wrangled into a single abstraction.
- rapnie 3y agoNewcomer here. Could anyone tell if std [0] is a good way to bring more sanity into flake design, esp. in avoiding ivory towery custom approaches? Using devenv.sh is another option, but I liked emphasis on creating a common mental picture of the architecture and focus on SLDC that std provides. [0] https://std.divnix.com https://std.divnix.com
- hamandcheese 3y agoI haven't used std, but I would like to point you at what I think is the ideal way to organize a lot of nix: readTree from the virus lounge[0]. It doesn't add kitschy terms like "Cell" and "growOn", it's just a way to standardize attribute names according to where things live in the filesystem. So in their repo, /foo/bar/baz.nix has the attribute path depot.foo.bar.baz I will say that to understand how it works you need to have a solid grasp of the nix language. But once established I think it's a pattern that noobs could learn in a very quick and superficial way. [0]: https://cs.tvl.fyi/depot/-/blob/nix/readTree/README.md https://cs.tvl.fyi/depot/-/blob/nix/readTree/README.md
- rapnie 3y agoThank you! I already bumped into the virus lounge, with their TVIX project [0] that I found quite interesting. [0] https://code.tvl.fyi/about/tvix https://code.tvl.fyi/about/tvix
- Cu3PO42 3y agoI really like this. In fact, I have an extremely similar home-grown abstraction. I might look into standardizing on this.
- OJFord 3y agoWhat on Earth is the background reading supposed to be for https://std.divnix.com/explain/why-std.html https://std.divnix.com/explain/why-std.html, a supposedly motivating page for newcomers? I've even used Nix a little bit (though early days, before flakes) and it makes absolutely no sense to me.
- rapnie 3y agoWell, I think that becomes clearer when reading comments on this HN thread. I found std after spending significant time to find out 1) wth is Nix/NixOS? 2) what would I use it for exactly? and 3) How to get going? Then on 3) I found reams of outdated or confusing docs making me doubt 1) and 2) again, as well as the frustrations of others on this. Then this std background of "We bring clarity, clear mental picture, manageable Nix projects throughout the lifecycle." appealed a lot.
- MadnessASAP 3y agoI thought I was weird for my bespoke ivory tower monorepo flake.nix, glad to hear I'm not the only one. It has been a tremendous help in managing my homelab.
- mkleczek 3y agoDoes Nix make it difficult to properly modularise nix files (flakes or not)? Because it certainly looks like the things you listed are separate/orthogonal and should be in separate modules/files. Having many years of Java experience this is the reason why I stick to Maven (not moving to Gradle) - it is opinionated and strongly encourages fine grained modularisation.
- yjftsjthsd-h 3y ago> Because it certainly looks like the things you listed are separate/orthogonal and should be in separate modules/files. Nix absolutely allows that, to the point where I'm surprised that the linked example doesn't separate them. Most of my flakes have a flake.nix that's just a thin wrapper around a block that looks like devShell = import ./shell.nix { inherit pkgs; }; defaultPackage = import ./default.nix { inherit pkgs; }; ...
- yencabulator 3y agoThe thing that makes that miserable is all the inputs need to be declared in the top-level flake. They really should make using flakes in subdirectories of the same git repo painless. (Right now they're treated as if they were remote, and you need to "upgrade" them after every change; unusable.)
- mkleczek 3y agoAnd what's the story with generic libraries that can later be used in your nix files to produce desired output? I am aware of flake-parts that are supposed to offer that but the ecosystem of flake-parts is on the smaller side of things...
- lkjdsklf 3y agoMaybe I'm not understanding your question, but this is what the inputs of flakes are for. You can pull in arbitrary code from pretty much anywhere as an input