2019-01-13 19:43:46 +02:00
|
|
|
let
|
|
|
|
drv = derivation {
|
|
|
|
name = "fail";
|
|
|
|
builder = "/bin/false";
|
|
|
|
system = "x86_64-linux";
|
|
|
|
outputs = [ "out" "foo" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
path = "${./eval-okay-context-introspection.nix}";
|
|
|
|
|
|
|
|
desired-context = {
|
|
|
|
"${builtins.unsafeDiscardStringContext path}" = {
|
|
|
|
path = true;
|
|
|
|
};
|
|
|
|
"${builtins.unsafeDiscardStringContext drv.drvPath}" = {
|
|
|
|
outputs = [ "foo" "out" ];
|
|
|
|
allOutputs = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-01-22 06:50:09 +02:00
|
|
|
combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
|
|
|
legit-context = builtins.getContext combo-path;
|
2019-01-14 18:34:54 +02:00
|
|
|
|
2023-01-22 06:50:09 +02:00
|
|
|
reconstructed-path = builtins.appendContext
|
|
|
|
(builtins.unsafeDiscardStringContext combo-path)
|
|
|
|
desired-context;
|
|
|
|
|
|
|
|
# Eta rule for strings with context.
|
|
|
|
etaRule = str:
|
|
|
|
str == builtins.appendContext
|
|
|
|
(builtins.unsafeDiscardStringContext str)
|
|
|
|
(builtins.getContext str);
|
|
|
|
|
2023-10-23 18:15:52 +03:00
|
|
|
# Only holds true if string context contains both a `DrvDeep` and
|
|
|
|
# `Opaque` element.
|
|
|
|
almostEtaRule = str:
|
|
|
|
str == builtins.addDrvOutputDependencies
|
|
|
|
(builtins.unsafeDiscardOutputDependency str);
|
|
|
|
|
|
|
|
addDrvOutputDependencies_idempotent = str:
|
|
|
|
builtins.addDrvOutputDependencies str ==
|
|
|
|
builtins.addDrvOutputDependencies (builtins.addDrvOutputDependencies str);
|
|
|
|
|
|
|
|
rules = str: [
|
|
|
|
(etaRule str)
|
|
|
|
(almostEtaRule str)
|
|
|
|
(addDrvOutputDependencies_idempotent str)
|
|
|
|
];
|
|
|
|
|
2023-01-22 06:50:09 +02:00
|
|
|
in [
|
|
|
|
(legit-context == desired-context)
|
|
|
|
(reconstructed-path == combo-path)
|
|
|
|
(etaRule "foo")
|
|
|
|
(etaRule drv.foo.outPath)
|
2023-10-23 18:15:52 +03:00
|
|
|
] ++ builtins.concatMap rules [
|
|
|
|
drv.drvPath
|
|
|
|
(builtins.addDrvOutputDependencies drv.drvPath)
|
|
|
|
(builtins.unsafeDiscardOutputDependency drv.drvPath)
|
2023-01-22 06:50:09 +02:00
|
|
|
]
|