feat(tvix/glue/derivationStrict): support __structuredAttrs

This adds support to handle the __structuredAttrs argument, which can be
passed to builtins.derivationStrict.

If __structuredAttrs is passed, and set to true, most of the arguments
passed to builtins.derivationStrict are not simply coerced to a string
and passed down to "environments", but instead kept in a more structured
fashion.

Inside ATerm, which is what's relevant as far as path calculation is
concerned, a virtual `__json` environment variable is present,
containing these structured values.

Inside Builds, these structured values are not made available as an
environment variable, but a JSON file (and source-able bash script).

This will need to be respected once we start emitting BuildRequests,
and for that we can probably just parse the `__json` key in
Derivation.environment again - or keep this additionally in
non-serialized form around during Evaluation.
No matter what, this is left for a followup CL.

The existing handle_derivation_parameters and populate_outputs helper
function were removed, as __structuredAttrs causes quite a change
in behaviour, and so handling both in the same place makes it more
readable.

There's some open questions w.r.t. string contexts for structured attrs
itself. A TODO is left for this, but at least path calculation for
individual structured attrs derivations are correct now.

Part of b/366.

Change-Id: Ic293822266ced6f8c4826d8ef0d2e098a4adccaa
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10604
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Florian Klink 2024-01-11 15:44:31 +02:00 committed by flokli
parent 82540717d6
commit d516ce56b1
6 changed files with 267 additions and 197 deletions

View file

@ -1000,9 +1000,9 @@ rec {
};
"bstr" = rec {
crateName = "bstr";
version = "1.6.0";
version = "1.9.0";
edition = "2021";
sha256 = "01bvsr3x9n75klbwxym0zf939vzim0plsmy786p0zzzvrj6i9637";
sha256 = "1p6hzf3wqwwynv6w4pn17jg21amfafph9kb5sfvf1idlli8h13y4";
authors = [
"Andrew Gallant <jamslam@gmail.com>"
];
@ -1027,7 +1027,7 @@ rec {
}
];
features = {
"alloc" = [ "serde?/alloc" ];
"alloc" = [ "memchr/alloc" "serde?/alloc" ];
"default" = [ "std" "unicode" ];
"serde" = [ "dep:serde" ];
"std" = [ "alloc" "memchr/std" "serde?/std" ];
@ -4315,9 +4315,9 @@ rec {
};
"memchr" = rec {
crateName = "memchr";
version = "2.5.0";
edition = "2018";
sha256 = "0vanfk5mzs1g1syqnj03q8n0syggnhn55dq535h2wxr7rwpfbzrd";
version = "2.7.1";
edition = "2021";
sha256 = "0jf1kicqa4vs9lyzj4v4y1p90q0dh87hvhsdd5xvhnp527sw8gaj";
authors = [
"Andrew Gallant <jamslam@gmail.com>"
"bluss"
@ -4326,11 +4326,12 @@ rec {
"compiler_builtins" = [ "dep:compiler_builtins" ];
"core" = [ "dep:core" ];
"default" = [ "std" ];
"libc" = [ "dep:libc" ];
"logging" = [ "dep:log" ];
"rustc-dep-of-std" = [ "core" "compiler_builtins" ];
"std" = [ "alloc" ];
"use_std" = [ "std" ];
};
resolvedDefaultFeatures = [ "default" "std" ];
resolvedDefaultFeatures = [ "alloc" "default" "std" ];
};
"memoffset 0.6.5" = rec {
crateName = "memoffset";
@ -6533,9 +6534,9 @@ rec {
};
"regex-automata" = rec {
crateName = "regex-automata";
version = "0.3.4";
version = "0.4.3";
edition = "2021";
sha256 = "156jmvsbzd9arih42ninzkfgv7g93g6i2fdxc5gki53m1ccxddmp";
sha256 = "0gs8q9yhd3kcg4pr00ag4viqxnh5l7jpyb9fsfr8hzh451w4r02z";
authors = [
"The Rust Project Developers"
"Andrew Gallant <jamslam@gmail.com>"
@ -6548,7 +6549,7 @@ rec {
"hybrid" = [ "alloc" "nfa-thompson" ];
"internal-instrument" = [ "internal-instrument-pikevm" ];
"internal-instrument-pikevm" = [ "logging" "std" ];
"logging" = [ "dep:log" "aho-corasick?/logging" ];
"logging" = [ "dep:log" "aho-corasick?/logging" "memchr?/logging" ];
"meta" = [ "syntax" "nfa-pikevm" ];
"nfa" = [ "nfa-thompson" "nfa-pikevm" "nfa-backtrack" ];
"nfa-backtrack" = [ "nfa-thompson" ];
@ -7685,9 +7686,9 @@ rec {
};
"serde" = rec {
crateName = "serde";
version = "1.0.162";
edition = "2015";
sha256 = "1dksgs0zi9wdh3bm3gzzsvmgg39fn8vb4d8gbz09haswmghzdcki";
version = "1.0.195";
edition = "2018";
sha256 = "00kbc86kgaihpza0zdglcd2qq5468yg0dvvdmkli2y660bs1s9k3";
authors = [
"Erick Tryzelaar <erick.tryzelaar@gmail.com>"
"David Tolnay <dtolnay@gmail.com>"
@ -7698,6 +7699,11 @@ rec {
packageId = "serde_derive";
optional = true;
}
{
name = "serde_derive";
packageId = "serde_derive";
target = { target, features }: false;
}
];
devDependencies = [
{
@ -7714,9 +7720,9 @@ rec {
};
"serde_derive" = rec {
crateName = "serde_derive";
version = "1.0.162";
version = "1.0.195";
edition = "2015";
sha256 = "1diwx4c86b63mgmzbd5nvj8imjwhipm48jlhi62bar7xa91q3852";
sha256 = "0b7ag1qm9q3fgwlmyk2ap5gjbqa9vyf2wfmj4xish6yq0f38zzj6";
procMacro = true;
authors = [
"Erick Tryzelaar <erick.tryzelaar@gmail.com>"
@ -10712,6 +10718,10 @@ rec {
then lib.cleanSourceWith { filter = sourceFilter; src = ./glue; }
else ./glue;
dependencies = [
{
name = "bstr";
packageId = "bstr";
}
{
name = "bytes";
packageId = "bytes";
@ -10724,6 +10734,14 @@ rec {
name = "nix-compat";
packageId = "nix-compat";
}
{
name = "serde";
packageId = "serde";
}
{
name = "serde_json";
packageId = "serde_json";
}
{
name = "sha2";
packageId = "sha2";