Hi, I have been working on a framework for making writing flakes simpler with less boilerplate.
I initially developed it for use in my projects, as existing flake libraries did not meet my expectations, though I intend this to be generally usable.
I would appreciate any feedback, especially on where documentation is lacking.
It supports setting the standard flake outputs as module config, handles generating package sets and per-system attributes, and supports loading nix files from a directory automatically. Packages are set as functions which will be called with callPackage, just like packages are written in nixpkgs.
Why another flake framework?
I’d started out with using flake-utils for its eachSystem function. Pulling in flake-utils everywhere ended up more overhead than necessary, so replaced it with a two-line simpler version of eachSystem I copied into each of my flakes. This was good for a while, but I found that the boilerplate in my flakes was kind of high, and there was a lot of common code to set up things like devShells and checks.
Thus, I ended up giving flake-parts a try since it seemed like it would fit my needs. The modular part seemed cool, but lacked what I wanted in the end, though there were a lot of parts I liked.
Reasons why I did not end up using flake-parts:
- Added significant complexity on top of base flakes, especially with how it handled its perSystem stuff using separate modules, and which one needed to understand to use it in a way that would fit my needs (did not seem fixable without breaking compatibility)
- Its overlays outputs just add the packages built using flake’s dependencies to the overlay, instead of building those packages with dependencies from the package set the overlay was applied to; while that type of overlay is sometimes useful, its definitely not what I would expect or want from the default
- Setting overlays on the package set required setting
_module.args.pkgswhich was boilerplate - It also output empty attributes which at the time showed up in
nix flake show(nix flake showignores them now, but I’d still rather not have empty attributes when I’m exploring the flake with eval or repl…) - Lacked modules that would populate flakes automatically (fixable by writing modules)
Now, to clarify, I’m not saying I think flake-parts is bad, but its not for me, so I decided to make my own thing. Especially, since if I ended up contributing to flake-parts, it would be best to have a proof-of-concept of ideas I wanted to implement. I ended up with an interface that deviated from flake-parts in compatibility breaking ways, so decided to just stick with mine.
For a more complex usage example, can see my config flake, which uses most flake outputs and where everything is loaded automatically from the nix directory: GitHub - accelbread/config-flake: Personal nix flake [MIRROR] · GitHub