2009-03-17 19:11:55 +02:00
|
|
|
with import ./config.nix;
|
|
|
|
|
2006-03-01 20:26:21 +02:00
|
|
|
rec {
|
|
|
|
|
2009-03-17 19:11:55 +02:00
|
|
|
f2 = dummy: builder: mode: algo: hash: mkDerivation {
|
2006-03-01 20:26:21 +02:00
|
|
|
name = "fixed";
|
2009-03-17 19:11:55 +02:00
|
|
|
inherit builder;
|
2006-03-01 20:26:21 +02:00
|
|
|
outputHashMode = mode;
|
|
|
|
outputHashAlgo = algo;
|
|
|
|
outputHash = hash;
|
2007-08-28 12:21:47 +03:00
|
|
|
inherit dummy;
|
2007-09-11 16:32:04 +03:00
|
|
|
impureEnvVars = ["IMPURE_VAR1" "IMPURE_VAR2"];
|
2006-03-01 20:26:21 +02:00
|
|
|
};
|
|
|
|
|
2007-08-28 12:21:47 +03:00
|
|
|
f = f2 "";
|
|
|
|
|
2006-03-01 20:26:21 +02:00
|
|
|
good = [
|
|
|
|
(f ./fixed.builder1.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
|
|
|
(f ./fixed.builder1.sh "flat" "sha1" "a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b")
|
|
|
|
(f ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
|
|
|
(f ./fixed.builder2.sh "recursive" "sha1" "vw46m23bizj4n8afrc0fj19wrp7mj3c0")
|
|
|
|
];
|
|
|
|
|
2021-09-26 16:20:36 +03:00
|
|
|
# Expression to test that `nix-build --check` also throws an error if the hash of
|
|
|
|
# fixed-output derivation has changed even if the hash exists in the store (in this
|
|
|
|
# case the hash exists because of `fixed.builder2.sh`, but building a derivation
|
|
|
|
# with the same hash and a different result must throw an error).
|
|
|
|
check = [
|
|
|
|
(f ./fixed.builder1.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
|
|
|
];
|
|
|
|
|
2006-03-01 20:26:21 +02:00
|
|
|
good2 = [
|
|
|
|
# Yes, this looks fscked up: builder2 doesn't have that result.
|
|
|
|
# But Nix sees that an output with the desired hash already
|
|
|
|
# exists, and will refrain from building it.
|
|
|
|
(f ./fixed.builder2.sh "flat" "md5" "8ddd8be4b179a529afa5f2ffae4b9858")
|
|
|
|
];
|
|
|
|
|
2008-12-03 17:06:30 +02:00
|
|
|
sameAsAdd =
|
|
|
|
f ./fixed.builder2.sh "recursive" "sha256" "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik";
|
|
|
|
|
2006-03-01 20:26:21 +02:00
|
|
|
bad = [
|
|
|
|
(f ./fixed.builder1.sh "flat" "md5" "0ddd8be4b179a529afa5f2ffae4b9858")
|
|
|
|
];
|
|
|
|
|
|
|
|
reallyBad = [
|
|
|
|
# Hash too short, and not base-32 either.
|
|
|
|
(f ./fixed.builder1.sh "flat" "md5" "ddd8be4b179a529afa5f2ffae4b9858")
|
|
|
|
];
|
|
|
|
|
2023-12-24 13:44:56 +02:00
|
|
|
badReferences = mkDerivation rec {
|
|
|
|
name = "bad-hash";
|
|
|
|
builder = script;
|
|
|
|
script = builtins.toFile "installer.sh" "echo $script >$out";
|
|
|
|
outputHash = "1ixr6yd3297ciyp9im522dfxpqbkhcw0pylkb2aab915278fqaik";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "flat";
|
|
|
|
};
|
|
|
|
|
2007-08-28 12:21:47 +03:00
|
|
|
# Test for building two derivations in parallel that produce the
|
|
|
|
# same output path because they're fixed-output derivations.
|
|
|
|
parallelSame = [
|
2007-08-28 14:31:44 +03:00
|
|
|
(f2 "foo" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
|
|
|
(f2 "bar" ./fixed.builder2.sh "recursive" "md5" "3670af73070fa14077ad74e0f5ea4e42")
|
2007-08-28 12:21:47 +03:00
|
|
|
];
|
|
|
|
|
2024-02-13 22:22:31 +02:00
|
|
|
# Can use "nar" instead of "recursive" now.
|
|
|
|
nar-not-recursive = f2 "foo" ./fixed.builder2.sh "nar" "md5" "3670af73070fa14077ad74e0f5ea4e42";
|
2007-08-28 14:31:44 +03:00
|
|
|
}
|