2023-04-20 00:36:33 +00:00
|
|
|
with import ./config.nix;
|
|
|
|
|
|
|
|
let innerName = "foo"; in
|
|
|
|
|
|
|
|
mkDerivation rec {
|
|
|
|
name = "${innerName}.drv";
|
|
|
|
SHELL = shell;
|
|
|
|
|
|
|
|
requiredSystemFeatures = [ "recursive-nix" ];
|
|
|
|
|
2023-05-05 15:49:41 +00:00
|
|
|
drv = builtins.unsafeDiscardOutputDependency (import ./text-hashed-output.nix).hello.drvPath;
|
2023-04-20 00:36:33 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
}
|