2020-08-07 21:09:26 +02:00
|
|
|
with import ./config.nix;
|
|
|
|
|
|
|
|
{ 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
|
2020-08-22 22:44:47 +02:00
|
|
|
rec {
|
2020-09-04 00:14:21 +02:00
|
|
|
rootLegacy = mkDerivation {
|
2020-09-04 00:44:56 +02:00
|
|
|
name = "simple-input-addressed";
|
2020-08-22 22:44:47 +02:00
|
|
|
buildCommand = ''
|
|
|
|
set -x
|
2020-09-04 00:14:21 +02:00
|
|
|
echo "Building a legacy derivation"
|
2020-08-22 22:44:47 +02:00
|
|
|
mkdir -p $out
|
|
|
|
echo "Hello World" > $out/hello
|
|
|
|
'';
|
|
|
|
};
|
2020-09-04 00:14:21 +02:00
|
|
|
rootCA = mkDerivation {
|
|
|
|
name = "dependent";
|
2020-09-04 16:38:45 +02:00
|
|
|
outputs = [ "out" "dev" ];
|
2020-09-04 00:14:21 +02:00
|
|
|
buildCommand = ''
|
|
|
|
echo "building a CA derivation"
|
|
|
|
echo "The seed is ${toString seed}"
|
|
|
|
mkdir -p $out
|
|
|
|
echo ${rootLegacy}/hello > $out/dep
|
2020-09-04 16:38:45 +02:00
|
|
|
# test symlink at root
|
|
|
|
ln -s $out $dev
|
2020-09-04 00:14:21 +02:00
|
|
|
'';
|
|
|
|
__contentAddressed = true;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
};
|
2020-09-04 00:44:56 +02:00
|
|
|
dependentCA = mkDerivation {
|
2020-08-22 22:44:47 +02:00
|
|
|
name = "dependent";
|
|
|
|
buildCommand = ''
|
|
|
|
echo "building a dependent derivation"
|
|
|
|
mkdir -p $out
|
2020-09-04 00:44:56 +02:00
|
|
|
echo ${rootCA}/hello > $out/dep
|
2020-08-22 22:44:47 +02:00
|
|
|
'';
|
|
|
|
__contentAddressed = true;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
};
|
2020-09-04 00:44:56 +02:00
|
|
|
transitivelyDependentCA = mkDerivation {
|
2020-08-22 22:44:47 +02:00
|
|
|
name = "transitively-dependent";
|
|
|
|
buildCommand = ''
|
|
|
|
echo "building transitively-dependent"
|
2020-09-04 00:44:56 +02:00
|
|
|
cat ${dependentCA}/dep
|
|
|
|
echo ${dependentCA} > $out
|
2020-08-22 22:44:47 +02:00
|
|
|
'';
|
|
|
|
__contentAddressed = true;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
};
|
2020-08-07 21:09:26 +02:00
|
|
|
}
|