aboutsummaryrefslogtreecommitdiff
path: root/tests/ca/content-addressed.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-04-05 19:06:30 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-04-05 19:06:30 -0400
commitcdc9f34a44aacbc8dbfa232a7620531a689d9c43 (patch)
tree11984c860dbc5c64bb2443737167f5ed4c1d1595 /tests/ca/content-addressed.nix
parent7863036634ccb07e1933cd0b106fc27d5c073004 (diff)
parente12308dd63f0ad27b22dcdb3da89c411eebcad2b (diff)
Merge commit 'e12308dd63f0ad27b22dcdb3da89c411eebcad2b' into ca-drv-exotic
Diffstat (limited to 'tests/ca/content-addressed.nix')
-rw-r--r--tests/ca/content-addressed.nix77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/ca/content-addressed.nix b/tests/ca/content-addressed.nix
new file mode 100644
index 000000000..e5b1c4de3
--- /dev/null
+++ b/tests/ca/content-addressed.nix
@@ -0,0 +1,77 @@
+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
+rec {
+ rootLegacy = mkDerivation {
+ name = "simple-input-addressed";
+ buildCommand = ''
+ set -x
+ echo "Building a legacy derivation"
+ mkdir -p $out
+ echo "Hello World" > $out/hello
+ '';
+ };
+ rootCA = mkDerivation {
+ 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
+ '';
+ __contentAddressed = true;
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ };
+ dependentCA = mkDerivation {
+ name = "dependent";
+ buildCommand = ''
+ echo "building a dependent derivation"
+ mkdir -p $out
+ cat ${rootCA}/self/dep
+ echo ${rootCA}/self/dep > $out/dep
+ '';
+ __contentAddressed = true;
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ };
+ transitivelyDependentCA = mkDerivation {
+ name = "transitively-dependent";
+ buildCommand = ''
+ echo "building transitively-dependent"
+ cat ${dependentCA}/dep
+ echo ${dependentCA} > $out
+ '';
+ __contentAddressed = true;
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ };
+ 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
+ '';
+ };
+ dependentFixedOutput = mkDerivation {
+ name = "dependent-fixed-output";
+ outputHashMode = "recursive";
+ outputHashAlgo = "sha256";
+ outputHash = "sha256-QvtAMbUl/uvi+LCObmqOhvNOapHdA2raiI4xG5zI5pA=";
+ buildCommand = ''
+ cat ${dependentCA}/dep
+ echo foo > $out
+ '';
+
+ };
+}