1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-25 03:39:36 +01:00
nix/src/libstore-tests/data
John Ericson 76bd600302 Parse deriving paths in DerivationOptions
This is an example of "Parse, don't validate" principle [1].

Before, we had a number of `StringSet`s in `DerivationOptions` that
were not *actually* allowed to be arbitrary sets of strings. Instead,
each set member had to be one of:

- a store path

- a CA "downstream placeholder"

- an output name

Only later, in the code that checks outputs, would these strings be
further parsed to match these cases. (Actually, only 2 by that point,
because the placeholders must be rewritten away by then.)

Now, we fully parse everything up front, and have an "honest" data type
that reflects these invariants:

- store paths are parsed, stored as (opaque) deriving paths

- CA "downstream placeholders" are rewritten to the output deriving
  paths they denote

- output names are the only arbitrary strings left

Since the first two cases both become deriving paths, that leaves us
with a `std::variant<SingleDerivedPath, String>` data type, which we use
in our sets instead.

Getting rid of placeholders is especially nice because we are replacing
them with something much more internally-structured / transparent.

[1]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/

Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2025-11-19 15:48:10 -05:00
..
build-result JSON Impl and schema for BuildResult 2025-11-03 18:25:16 -05:00
common-protocol JSON alongside binary proto serialization test data 2025-11-10 18:32:31 -05:00
content-address nlohmann::json instance and JSON Schema for ContentAddress 2025-10-27 14:47:50 -04:00
derivation Parse deriving paths in DerivationOptions 2025-11-19 15:48:10 -05:00
derived-path Modernize and test derived path JSON 2025-09-23 15:05:56 -04:00
machines Move unit tests to the location Meson expects them to be 2024-10-17 15:42:16 -04:00
nar-info Futher cleans up store object info JSON v2 2025-11-06 23:28:56 -05:00
outputs-spec Convert {Extended,}OutputsSpec JSON tests to characterization tests 2025-09-23 14:47:00 -04:00
path-info Futher cleans up store object info JSON v2 2025-11-06 23:28:56 -05:00
realisation Add JSON tests for Realisation 2025-09-24 18:09:24 -04:00
serve-protocol JSON alongside binary proto serialization test data 2025-11-10 18:32:31 -05:00
store-path Make the JSON format for derivation use basename store paths 2025-09-17 16:38:17 -04:00
store-reference libstore: Improve store-reference back-compat with IPv6 ZoneId literals 2025-11-01 00:36:15 +03:00
worker-protocol JSON alongside binary proto serialization test data 2025-11-10 18:32:31 -05:00