mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Merge remote-tracking branch 'upstream/master' into indexed-store-path-outputs
This commit is contained in:
commit
b585548dfe
74 changed files with 1925 additions and 566 deletions
105
tests/fetchTree-file.sh
Normal file
105
tests/fetchTree-file.sh
Normal file
|
@ -0,0 +1,105 @@
|
|||
source common.sh
|
||||
|
||||
clearStore
|
||||
|
||||
cd "$TEST_ROOT"
|
||||
|
||||
test_fetch_file () {
|
||||
echo foo > test_input
|
||||
|
||||
input_hash="$(nix hash path test_input)"
|
||||
|
||||
nix eval --impure --file - <<EOF
|
||||
let
|
||||
tree = builtins.fetchTree { type = "file"; url = "file://$PWD/test_input"; };
|
||||
in
|
||||
assert (tree.narHash == "$input_hash");
|
||||
tree
|
||||
EOF
|
||||
}
|
||||
|
||||
# Make sure that `http(s)` and `file` flake inputs are properly extracted when
|
||||
# they should be, and treated as opaque files when they should be
|
||||
test_file_flake_input () {
|
||||
rm -fr "$TEST_ROOT/testFlake";
|
||||
mkdir "$TEST_ROOT/testFlake";
|
||||
pushd testFlake
|
||||
|
||||
mkdir inputs
|
||||
echo foo > inputs/test_input_file
|
||||
tar cfa test_input.tar.gz inputs
|
||||
cp test_input.tar.gz test_input_no_ext
|
||||
input_tarball_hash="$(nix hash path test_input.tar.gz)"
|
||||
input_directory_hash="$(nix hash path inputs)"
|
||||
|
||||
cat <<EOF > flake.nix
|
||||
{
|
||||
inputs.no_ext_default_no_unpack = {
|
||||
url = "file://$PWD/test_input_no_ext";
|
||||
flake = false;
|
||||
};
|
||||
inputs.no_ext_explicit_unpack = {
|
||||
url = "tarball+file://$PWD/test_input_no_ext";
|
||||
flake = false;
|
||||
};
|
||||
inputs.tarball_default_unpack = {
|
||||
url = "file://$PWD/test_input.tar.gz";
|
||||
flake = false;
|
||||
};
|
||||
inputs.tarball_explicit_no_unpack = {
|
||||
url = "file+file://$PWD/test_input.tar.gz";
|
||||
flake = false;
|
||||
};
|
||||
outputs = { ... }: {};
|
||||
}
|
||||
EOF
|
||||
|
||||
nix flake update
|
||||
nix eval --file - <<EOF
|
||||
with (builtins.fromJSON (builtins.readFile ./flake.lock));
|
||||
|
||||
# Url inputs whose extension doesn’t match a know archive format should
|
||||
# not be unpacked by default
|
||||
assert (nodes.no_ext_default_no_unpack.locked.type == "file");
|
||||
assert (nodes.no_ext_default_no_unpack.locked.unpack or false == false);
|
||||
assert (nodes.no_ext_default_no_unpack.locked.narHash == "$input_tarball_hash");
|
||||
|
||||
# For backwards compatibility, flake inputs that correspond to the
|
||||
# old 'tarball' fetcher should still have their type set to 'tarball'
|
||||
assert (nodes.tarball_default_unpack.locked.type == "tarball");
|
||||
# Unless explicitely specified, the 'unpack' parameter shouldn’t appear here
|
||||
# because that would break older Nix versions
|
||||
assert (!nodes.tarball_default_unpack.locked ? unpack);
|
||||
assert (nodes.tarball_default_unpack.locked.narHash == "$input_directory_hash");
|
||||
|
||||
# Explicitely passing the unpack parameter should enforce the desired behavior
|
||||
assert (nodes.no_ext_explicit_unpack.locked.narHash == nodes.tarball_default_unpack.locked.narHash);
|
||||
assert (nodes.tarball_explicit_no_unpack.locked.narHash == nodes.no_ext_default_no_unpack.locked.narHash);
|
||||
true
|
||||
EOF
|
||||
popd
|
||||
|
||||
[[ -z "${NIX_DAEMON_PACKAGE}" ]] && return 0
|
||||
|
||||
# Ensure that a lockfile generated by the current Nix for tarball inputs
|
||||
# can still be read by an older Nix
|
||||
|
||||
cat <<EOF > flake.nix
|
||||
{
|
||||
inputs.tarball = {
|
||||
url = "file://$PWD/test_input.tar.gz";
|
||||
flake = false;
|
||||
};
|
||||
outputs = { self, tarball }: {
|
||||
foo = builtins.readFile "${tarball}/test_input_file";
|
||||
};
|
||||
}
|
||||
nix flake update
|
||||
|
||||
clearStore
|
||||
"$NIX_DAEMON_PACKAGE/bin/nix" eval .#foo
|
||||
EOF
|
||||
}
|
||||
|
||||
test_fetch_file
|
||||
test_file_flake_input
|
|
@ -163,6 +163,7 @@ nix build -o $TEST_ROOT/result --expr "(builtins.getFlake \"git+file://$flake1Di
|
|||
# But should succeed in impure mode.
|
||||
(! nix build -o $TEST_ROOT/result flake2#bar --impure)
|
||||
nix build -o $TEST_ROOT/result flake2#bar --impure --no-write-lock-file
|
||||
nix eval --expr "builtins.getFlake \"$flake2Dir\"" --impure
|
||||
|
||||
# Building a local flake with an unlocked dependency should fail with --no-update-lock-file.
|
||||
nix build -o $TEST_ROOT/result $flake2Dir#bar --no-update-lock-file 2>&1 | grep 'requires lock file changes'
|
||||
|
|
3
tests/lang/parse-fail-eof-in-string.nix
Normal file
3
tests/lang/parse-fail-eof-in-string.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
# https://github.com/NixOS/nix/issues/6562
|
||||
# Note that this file must not end with a newline.
|
||||
a 1"$
|
|
@ -23,6 +23,7 @@ nix_tests = \
|
|||
fetchGit.sh \
|
||||
fetchurl.sh \
|
||||
fetchPath.sh \
|
||||
fetchTree-file.sh \
|
||||
simple.sh \
|
||||
referrers.sh \
|
||||
optimise-store.sh \
|
||||
|
|
|
@ -120,3 +120,21 @@ nix profile install "$flake1Dir^man"
|
|||
(! [ -e $TEST_HOME/.nix-profile/bin/hello ])
|
||||
[ -e $TEST_HOME/.nix-profile/share/man ]
|
||||
(! [ -e $TEST_HOME/.nix-profile/include ])
|
||||
|
||||
# test priority
|
||||
nix profile remove 0
|
||||
|
||||
# Make another flake.
|
||||
flake2Dir=$TEST_ROOT/flake2
|
||||
printf World > $flake1Dir/who
|
||||
cp -r $flake1Dir $flake2Dir
|
||||
printf World2 > $flake2Dir/who
|
||||
|
||||
nix profile install $flake1Dir
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
nix profile install $flake2Dir --priority 100
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
nix profile install $flake2Dir --priority 0
|
||||
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World2" ]]
|
||||
# nix profile install $flake1Dir --priority 100
|
||||
# [[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello World" ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue