2020-11-09 15:04:18 +00:00
|
|
|
with import ../config.nix;
|
2020-08-07 19:09:26 +00:00
|
|
|
|
|
|
|
{ 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 20:44:47 +00:00
|
|
|
rec {
|
2020-09-03 22:14:21 +00:00
|
|
|
rootLegacy = mkDerivation {
|
2020-09-03 22:44:56 +00:00
|
|
|
name = "simple-input-addressed";
|
2020-08-22 20:44:47 +00:00
|
|
|
buildCommand = ''
|
|
|
|
set -x
|
2020-09-03 22:14:21 +00:00
|
|
|
echo "Building a legacy derivation"
|
2020-08-22 20:44:47 +00:00
|
|
|
mkdir -p $out
|
|
|
|
echo "Hello World" > $out/hello
|
|
|
|
'';
|
|
|
|
};
|
2020-09-03 22:14:21 +00:00
|
|
|
rootCA = mkDerivation {
|
2020-09-23 14:30:42 +00:00
|
|
|
name = "rootCA";
|
2020-11-25 10:20:03 +00:00
|
|
|
outputs = [ "out" "dev" "foo"];
|
2020-09-03 22:14:21 +00:00
|
|
|
buildCommand = ''
|
|
|
|
echo "building a CA derivation"
|
|
|
|
echo "The seed is ${toString seed}"
|
|
|
|
mkdir -p $out
|
|
|
|
echo ${rootLegacy}/hello > $out/dep
|
2020-11-25 10:20:03 +00:00
|
|
|
ln -s $out $out/self
|
|
|
|
# test symlinks at root
|
2020-09-04 14:38:45 +00:00
|
|
|
ln -s $out $dev
|
2020-11-25 10:20:03 +00:00
|
|
|
ln -s $out $foo
|
2020-09-03 22:14:21 +00:00
|
|
|
'';
|
|
|
|
__contentAddressed = true;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
};
|
2020-09-03 22:44:56 +00:00
|
|
|
dependentCA = mkDerivation {
|
2020-08-22 20:44:47 +00:00
|
|
|
name = "dependent";
|
|
|
|
buildCommand = ''
|
|
|
|
echo "building a dependent derivation"
|
|
|
|
mkdir -p $out
|
2020-11-25 10:20:03 +00:00
|
|
|
cat ${rootCA}/self/dep
|
|
|
|
echo ${rootCA}/self/dep > $out/dep
|
2020-08-22 20:44:47 +00:00
|
|
|
'';
|
|
|
|
__contentAddressed = true;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
};
|
2020-09-03 22:44:56 +00:00
|
|
|
transitivelyDependentCA = mkDerivation {
|
2020-08-22 20:44:47 +00:00
|
|
|
name = "transitively-dependent";
|
|
|
|
buildCommand = ''
|
|
|
|
echo "building transitively-dependent"
|
2020-09-03 22:44:56 +00:00
|
|
|
cat ${dependentCA}/dep
|
|
|
|
echo ${dependentCA} > $out
|
2020-08-22 20:44:47 +00:00
|
|
|
'';
|
|
|
|
__contentAddressed = true;
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
};
|
2020-09-23 14:30:42 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
2020-11-25 17:20:35 +00:00
|
|
|
dependentFixedOutput = mkDerivation {
|
|
|
|
name = "dependent-fixed-output";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHash = "sha256-QvtAMbUl/uvi+LCObmqOhvNOapHdA2raiI4xG5zI5pA=";
|
|
|
|
buildCommand = ''
|
|
|
|
cat ${dependentCA}/dep
|
|
|
|
echo foo > $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
2020-08-07 19:09:26 +00:00
|
|
|
}
|