mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02:00
parent
ee3f0b7a8b
commit
8690b6f138
2 changed files with 47 additions and 11 deletions
|
@ -1,7 +1,6 @@
|
||||||
with import ./config.nix;
|
with import ./config.nix;
|
||||||
|
|
||||||
let
|
rec {
|
||||||
|
|
||||||
bar = mkDerivation {
|
bar = mkDerivation {
|
||||||
name = "bar";
|
name = "bar";
|
||||||
builder = builtins.toFile "builder.sh"
|
builder = builtins.toFile "builder.sh"
|
||||||
|
@ -15,12 +14,20 @@ let
|
||||||
assert builtins.pathExists bar;
|
assert builtins.pathExists bar;
|
||||||
import bar;
|
import bar;
|
||||||
|
|
||||||
in
|
result = mkDerivation {
|
||||||
|
name = "foo";
|
||||||
|
builder = builtins.toFile "builder.sh"
|
||||||
|
''
|
||||||
|
echo -n FOO${toString value} > $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
mkDerivation {
|
addPath = mkDerivation {
|
||||||
name = "foo";
|
name = "add-path";
|
||||||
builder = builtins.toFile "builder.sh"
|
src = builtins.filterSource (path: type: true) result;
|
||||||
''
|
builder = builtins.toFile "builder.sh"
|
||||||
echo -n FOO${toString value} > $out
|
''
|
||||||
'';
|
echo -n BLA$(cat $src) > $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,40 @@ source common.sh
|
||||||
|
|
||||||
clearStoreIfPossible
|
clearStoreIfPossible
|
||||||
|
|
||||||
if nix-instantiate --readonly-mode ./import-from-derivation.nix; then
|
if nix-instantiate --readonly-mode ./import-from-derivation.nix -A result; then
|
||||||
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
outPath=$(nix-build ./import-from-derivation.nix --no-out-link)
|
outPath=$(nix-build ./import-from-derivation.nix -A result --no-out-link)
|
||||||
|
|
||||||
[ "$(cat "$outPath")" = FOO579 ]
|
[ "$(cat "$outPath")" = FOO579 ]
|
||||||
|
|
||||||
|
# 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
|
||||||
|
nix copy --to "$store2_url" --no-check-sigs "$(nix-build ./import-from-derivation.nix -A $i --no-out-link)"
|
||||||
|
done
|
||||||
|
|
||||||
|
clearStore
|
||||||
|
|
||||||
|
outPath_check=$(nix-build ./import-from-derivation.nix -A result --no-out-link --store "$store2_url")
|
||||||
|
[[ "$outPath" = "$outPath_check" ]]
|
||||||
|
[[ ! -e "$outPath" ]]
|
||||||
|
[[ -e "$store2/nix/store/$(basename $outPath)" ]]
|
||||||
|
|
||||||
|
outPath2_check=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link --store "$store2_url")
|
||||||
|
[[ "$outPath2" = "$outPath2_check" ]]
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue