2024-05-28 16:43:04 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2012-01-26 13:04:50 +00:00
|
|
|
source common.sh
|
|
|
|
|
2024-09-18 17:06:48 +00:00
|
|
|
TODO_NixOS
|
|
|
|
|
2024-06-16 15:56:50 +00:00
|
|
|
clearStoreIfPossible
|
2012-01-26 13:04:50 +00:00
|
|
|
|
2024-09-18 10:42:20 +00:00
|
|
|
if nix-instantiate --readonly-mode ./import-from-derivation.nix -A result; then
|
2012-01-26 13:04:50 +00:00
|
|
|
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-09-18 10:42:20 +00:00
|
|
|
outPath=$(nix-build ./import-from-derivation.nix -A result --no-out-link)
|
2012-01-26 13:04:50 +00:00
|
|
|
|
2024-06-04 20:33:59 +00:00
|
|
|
[ "$(cat "$outPath")" = FOO579 ]
|
2024-09-18 10:42:20 +00:00
|
|
|
|
2024-09-18 17:06:48 +00:00
|
|
|
# FIXME: the next tests are broken on CA.
|
|
|
|
if [[ -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2024-09-18 10:42:20 +00:00
|
|
|
# Test filterSource on the result of a derivation.
|
|
|
|
outPath2=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link)
|
|
|
|
[[ "$(cat "$outPath2")" = BLAFOO579 ]]
|
|
|
|
|
|
|
|
# Test that IFD works with a chroot store.
|
|
|
|
if canUseSandbox; then
|
|
|
|
|
|
|
|
store2="$TEST_ROOT/store2"
|
|
|
|
store2_url="$store2?store=$NIX_STORE_DIR"
|
|
|
|
|
|
|
|
# Copy the derivation outputs to the chroot store to avoid having
|
|
|
|
# to actually build anything, as that would fail due to the lack
|
|
|
|
# of a shell in the sandbox. We only care about testing the IFD
|
|
|
|
# semantics.
|
|
|
|
for i in bar result addPath; do
|
2024-09-18 16:05:08 +00:00
|
|
|
nix copy --to "$store2_url" --no-check-sigs "$(nix-build ./import-from-derivation.nix -A "$i" --no-out-link)"
|
2024-09-18 10:42:20 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
clearStore
|
|
|
|
|
|
|
|
outPath_check=$(nix-build ./import-from-derivation.nix -A result --no-out-link --store "$store2_url")
|
|
|
|
[[ "$outPath" = "$outPath_check" ]]
|
|
|
|
[[ ! -e "$outPath" ]]
|
2024-09-18 16:05:08 +00:00
|
|
|
[[ -e "$store2/nix/store/$(basename "$outPath")" ]]
|
2024-09-18 10:42:20 +00:00
|
|
|
|
|
|
|
outPath2_check=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link --store "$store2_url")
|
|
|
|
[[ "$outPath2" = "$outPath2_check" ]]
|
|
|
|
fi
|