Show HN: Flake schemas – teaching Nix about your flake outputs
determinate.systems
determinate.systems
The lack of a reasonable type system is one of the biggest Nix problems.
Coupled with https://github.com/nickel-lang/organist
I’m not sure how immature it is though.
In terms of this decomposition effort, one additional thing that would be really nice to see would be turning flake URL schemes & updaters extensible. One could imagine some kind of a dictionary that maps from schemes to derivations that contain the code needed to get the primitive URL for the "latest" version of the flake when an update is called for.
The tl;dr, though:
* nix flake show and other tools only knew about very specific types of things you might put in a flake.
* with flake-schemas, that limitation is lifted and people can do more creative things.
But what if you want your flake to output a library? A Dockerfile? A Terraform or Kubernetes config? Nix doesn't know about those custom outputs, and doesn't have a way to validate that you're using them correctly.
Now with Flake Schemas, you can provide a schema so that built in tools like `nix flake show` and `nix flake check` can properly validate the new output. This makes it easier for Flake developers to communicate the interface of their custom output to Flake consumers
Until this post/your comment I didn’t know flakes could even have custom outputs. I guess they’re all just conventions for attribute names, and everything is a derivation, so it makes sense. But realizing that point was key, even with passing nix familiarity.
I still find much of the syntax incredibly confusing and hard to just get simple concrete self contained examples, or without worrying if this is intermingled with some non flake code somewhere that isn't compatible.
I've bumped a few nix packages via github PR's and can hack around a bit with existing things I see upstream, but knowing how to do everything is still confusing.
I guess I need to sit down and read all of https://zero-to-nix.com/ and see if there is anything I'm missing.