Nix-derivation 0.1

Parses, validates, hashes, and serializes Nix derivations and constructs their store paths in pure Rust

Disclaimer: LLMs have been used

7 Likes

Nix master has recently landed changes that create a separation between the low-level representation and a more high level representation.
It means that consumers of the new types can focus on the meaning rather than how that maps to the current 20+ year old format that’s been layered on top of.

Output hashing modulo meta will fit nicely on top of those (rebase incoming). I know you’ll like that one :smiley:

Most notable refactor I think is libstore: compute the hash modulo via an intermediate derivation by amaanq · Pull Request #16191 · NixOS/nix · GitHub

I suppose your library is only slightly above the ATerm level?
That’s already good enough for most applications, including extracting the meta field, but if you want to also write derivations, the extra layering becomes useful.

8 Likes

Hey Robert,

Thanks for chipping in!

I’ve opened Align derivation modulo hashing with Nix master by domenkozar · Pull Request #1 · cachix/nix-derivation · GitHub to catch up!

This one makes my day :slight_smile: What kind of help do you need to get it merged?

Draft PR for nix-derivation: Add proposed derivation metadata semantics by domenkozar · Pull Request #2 · cachix/nix-derivation · GitHub

Your “slightly above the ATerm level” characterization was fair for 0.1. It had semantic output types, but serialization and hashing still shared the low-level representation through a boolean masking mode. Should be fixed now in #1.

1 Like

I’ve released nix-derivation 0.2 with these changes, more performance tuning and overall cleaning up of the interface.

1 Like

nix-derivation 0.3 released with custom store prefix support such as /gnu/store

2 Likes

nix-derivation 0.4.0 adds support for Nix 2.35 dynamic derivations:

  • Typed, validated downstream dynamic-output placeholders.
  • Queries for dynamic-derivation usage, required system features, and exportReferencesGraph.
  • Typed dynamic-input resolution across builders, arguments, environment variables, and structured attributes.
1 Like