diff options
author | Shea Levy <shea@shealevy.com> | 2024-01-11 07:21:16 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2024-01-11 07:21:16 -0500 |
commit | ba48ab4b954dd1c8af388d1c5a33bbd62373c6f5 (patch) | |
tree | f17f8492bed32f78c04d9d4e9ffd2b672af85943 /tests/functional/ca/content-addressed.nix | |
parent | e7c2b35827e9f4ddbec4248c5cf1ad793a2988ad (diff) | |
parent | 4dd5171652018e29bf9e496522df3be51d615a2c (diff) |
Merge branch '2.18-maintenance' into ifd-buildStore-2.18
Diffstat (limited to 'tests/functional/ca/content-addressed.nix')
-rw-r--r-- | tests/functional/ca/content-addressed.nix | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/tests/functional/ca/content-addressed.nix b/tests/functional/ca/content-addressed.nix new file mode 100644 index 000000000..2559c562f --- /dev/null +++ b/tests/functional/ca/content-addressed.nix @@ -0,0 +1,100 @@ +with import ./config.nix; + +let mkCADerivation = args: mkDerivation ({ + __contentAddressed = true; + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; +} // args); +in + +{ seed ? 0 }: +# A simple content-addressed derivation. +# The derivation can be arbitrarily modified by passing a different `seed`, +# but the output will always be the same +rec { + rootLegacy = mkDerivation { + name = "simple-input-addressed"; + buildCommand = '' + set -x + echo "Building a legacy derivation" + mkdir -p $out + echo "Hello World" > $out/hello + ''; + }; + rootCA = mkCADerivation { + name = "rootCA"; + outputs = [ "out" "dev" "foo" ]; + buildCommand = '' + echo "building a CA derivation" + echo "The seed is ${toString seed}" + mkdir -p $out + echo ${rootLegacy}/hello > $out/dep + ln -s $out $out/self + # test symlinks at root + ln -s $out $dev + ln -s $out $foo + ''; + }; + dependentCA = mkCADerivation { + name = "dependent"; + buildCommand = '' + echo "building a dependent derivation" + mkdir -p $out + cat ${rootCA}/self/dep + echo ${rootCA}/self/dep > $out/dep + ''; + }; + transitivelyDependentCA = mkCADerivation { + name = "transitively-dependent"; + buildCommand = '' + echo "building transitively-dependent" + cat ${dependentCA}/dep + echo ${dependentCA} > $out + ''; + }; + dependentNonCA = mkDerivation { + name = "dependent-non-ca"; + buildCommand = '' + echo "Didn't cut-off" + echo "building dependent-non-ca" + mkdir -p $out + echo ${rootCA}/non-ca-hello > $out/dep + ''; + }; + dependentForBuildCA = mkCADerivation { + name = "dependent-for-build-ca"; + buildCommand = '' + echo "Depends on rootCA for building only" + mkdir -p $out + echo ${rootCA} + touch $out + ''; + }; + dependentForBuildNonCA = mkDerivation { + name = "dependent-for-build-non-ca"; + buildCommand = '' + echo "Depends on rootCA for building only" + mkdir -p $out + echo ${rootCA} + touch $out + ''; + }; + dependentFixedOutput = mkDerivation { + name = "dependent-fixed-output"; + outputHashMode = "recursive"; + outputHash = "sha512-7aJcmSuEuYP5tGKcmGY8bRr/lrCjJlOxP2mIUjO/vMQeg6gx/65IbzRWES8EKiPDOs9z+wF30lEfcwxM/cT4pw=="; + buildCommand = '' + cat ${dependentCA}/dep + echo foo > $out + ''; + }; + runnable = mkCADerivation rec { + name = "runnable-thing"; + buildCommand = '' + mkdir -p $out/bin + echo ${rootCA} # Just to make it depend on it + echo "#! ${shell}" > $out/bin/${name} + chmod +x $out/bin/${name} + ''; + }; +} |