diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-04-19 20:36:33 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-04-19 20:36:33 -0400 |
commit | e26662709e4f458e0916d43a613d44b174ad4679 (patch) | |
tree | 92744f40e38d746b298395c7c1907620a6a00a44 /tests/dyn-drv/recursive-mod-json.nix | |
parent | f3a31b14db6629ec424f31842157e6f614231bcd (diff) |
Add a more interesting test
In this one, we don't just output an existing derivation as is, but
modify it first.
Diffstat (limited to 'tests/dyn-drv/recursive-mod-json.nix')
-rw-r--r-- | tests/dyn-drv/recursive-mod-json.nix | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/dyn-drv/recursive-mod-json.nix b/tests/dyn-drv/recursive-mod-json.nix new file mode 100644 index 000000000..9b32c55e9 --- /dev/null +++ b/tests/dyn-drv/recursive-mod-json.nix @@ -0,0 +1,33 @@ +with import ./config.nix; + +let innerName = "foo"; in + +mkDerivation rec { + name = "${innerName}.drv"; + SHELL = shell; + + requiredSystemFeatures = [ "recursive-nix" ]; + + drv = builtins.unsafeDiscardOutputDependency (import ./text-hashed-output.nix).root.drvPath; + + buildCommand = '' + export NIX_CONFIG='experimental-features = nix-command ca-derivations' + + PATH=${builtins.getEnv "EXTRA_PATH"}:$PATH + + # JSON of pre-existing drv + nix derivation show $drv | jq .[] > drv0.json + + # Fix name + jq < drv0.json '.name = "${innerName}"' > drv1.json + + # Extend `buildCommand` + jq < drv1.json '.env.buildCommand += "echo \"I am alive!\" >> $out/hello\n"' > drv0.json + + # Used as our output + cp $(nix derivation add < drv0.json) $out + ''; + __contentAddressed = true; + outputHashMode = "text"; + outputHashAlgo = "sha256"; +} |