diff --git a/tests/hermetic.nix b/tests/hermetic.nix new file mode 100644 index 000000000..7ccd0fd72 --- /dev/null +++ b/tests/hermetic.nix @@ -0,0 +1,56 @@ +{ busybox }: + +with import ./config.nix; + +let + contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1"; + caArgs = if contentAddressedByDefault then { + __contentAddressed = true; + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + } else {}; + + mkDerivation = args: + derivation ({ + inherit system; + builder = busybox; + args = ["sh" "-e" args.builder or (builtins.toFile "builder-${args.name}.sh" "if [ -e .attrs.sh ]; then source .attrs.sh; fi; eval \"$buildCommand\"")]; + } // removeAttrs args ["builder" "meta" "passthru"] + // caArgs) + // { meta = args.meta or {}; passthru = args.passthru or {}; }; + + input1 = mkDerivation { + shell = busybox; + name = "build-remote-input-1"; + buildCommand = "echo hi-input1; echo FOO > $out"; + }; + + input2 = mkDerivation { + shell = busybox; + name = "build-remote-input-2"; + buildCommand = "echo hi; echo BAR > $out"; + }; + + input3 = mkDerivation { + shell = busybox; + name = "build-remote-input-3"; + buildCommand = '' + echo hi-input3 + read x < ${input2} + echo $x BAZ > $out + ''; + }; + +in + + mkDerivation { + shell = busybox; + name = "build-remote"; + passthru = { inherit input1 input2 input3; }; + buildCommand = + '' + read x < ${input1} + read y < ${input3} + echo "$x $y" > $out + ''; + } diff --git a/tests/overlay-local-store.sh b/tests/overlay-local-store.sh index 6c0a5f96d..c98931118 100644 --- a/tests/overlay-local-store.sh +++ b/tests/overlay-local-store.sh @@ -1,3 +1,7 @@ source common.sh +requireSandboxSupport +[[ $busybox =~ busybox ]] || skipTest "no busybox" +if [[ $(uname) != Linux ]]; then skipTest "Need Linux for overlayfs"; fi + exec unshare --mount --map-root-user overlay-local-store/inner.sh diff --git a/tests/overlay-local-store/inner.sh b/tests/overlay-local-store/inner.sh index fb690a85f..5079dd0bd 100755 --- a/tests/overlay-local-store/inner.sh +++ b/tests/overlay-local-store/inner.sh @@ -11,13 +11,16 @@ export NIX_CONFIG='build-users-group = ' # Creating testing directories storeA="$TEST_ROOT/store_a" -storeB="$TEST_ROOT/store_b?real=$TEST_ROOT/merged-store" +storeB="local-overlay?root=$TEST_ROOT/store_b&lower-store=$TEST_ROOT/merged-store" storeBTop="$TEST_ROOT/store_b" mkdir -p "$TEST_ROOT"/{store_a,store_b,merged-store,workdir} # Mounting Overlay Store +## Restore normal, because we are using these chroot stores +#NIX_STORE_DIR=/nix/store + nix-store --store "$TEST_ROOT/store_a" --add dummy nix-store --store "$TEST_ROOT/store_b" --add dummy @@ -27,7 +30,14 @@ mount -t overlay overlay \ -o workdir="$TEST_ROOT/workdir" \ "$TEST_ROOT/merged-store" || skipTest "overlayfs is not supported" -path_a=$(nix-build '' -A signal-desktop --store "$storeA") +# Add in lower +NIX_REMOTE=$storeA source add.sh + +# Add in layered +NIX_REMOTE=$storeB source add.sh + +#busyboxExpr="\"\${$(dirname "$busybox")}/$(basename "$busybox")\"" +path_a=$(nix-build ./hermetic.nix --arg busybox "$busybox" --store "$storeA") # Checking for Path in store_a stat "$TEST_ROOT/store_a/$path_a" @@ -48,4 +58,4 @@ expect 1 nix-store --verify-path --store "$storeB" "$path_a" # Verifying path in store_b (Should fail) expect 1 nix-store --verify-path --store "$storeBTop" "$path_a" -path_b=$(nix-build '' -A signal-desktop --store "$storeB") +path_b=$(nix-build ./hermetic.nix --arg busybox $busybox --store "$storeB")