1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-24 09:50:55 +01:00

Merge remote-tracking branch 'detsys/detsys-main' into lazy-trees-tmp

This commit is contained in:
Eelco Dolstra 2025-04-23 12:25:28 +02:00
commit a6faa69fc8
109 changed files with 1219 additions and 546 deletions

View file

@ -28,6 +28,7 @@ suites += {
'commit-lock-file-summary.sh',
'non-flake-inputs.sh',
'relative-paths.sh',
'relative-paths-lockfile.sh',
'symlink-paths.sh',
'debugger.sh',
'source-paths.sh',

View file

@ -0,0 +1,73 @@
#!/usr/bin/env bash
source ./common.sh
requireGit
# Test a "vendored" subflake dependency. This is a relative path flake
# which doesn't reference the root flake and has its own lock file.
#
# This might occur in a monorepo for example. The root flake.lock is
# populated from the dependency's flake.lock.
rootFlake="$TEST_ROOT/flake1"
subflake="$rootFlake/sub"
depFlakeA="$TEST_ROOT/depFlakeA"
depFlakeB="$TEST_ROOT/depFlakeB"
rm -rf "$rootFlake"
mkdir -p "$rootFlake" "$subflake" "$depFlakeA" "$depFlakeB"
cat > "$depFlakeA/flake.nix" <<EOF
{
outputs = { self }: {
x = 11;
};
}
EOF
cat > "$depFlakeB/flake.nix" <<EOF
{
outputs = { self }: {
x = 13;
};
}
EOF
[[ $(nix eval "$depFlakeA#x") = 11 ]]
[[ $(nix eval "$depFlakeB#x") = 13 ]]
cat > "$subflake/flake.nix" <<EOF
{
inputs.dep.url = "path:$depFlakeA";
outputs = { self, dep }: {
inherit (dep) x;
y = self.x - 1;
};
}
EOF
cat > "$rootFlake/flake.nix" <<EOF
{
inputs.sub.url = ./sub;
outputs = { self, sub }: {
x = 2;
y = sub.y / self.x;
};
}
EOF
[[ $(nix eval "$subflake#y") = 10 ]]
[[ $(nix eval "$rootFlake#y") = 5 ]]
nix flake update --flake "path:$subflake" --override-input dep "$depFlakeB"
[[ $(nix eval "path:$subflake#y") = 12 ]]
# Expect that changes to sub/flake.lock are propagated to the root flake.
# FIXME: doesn't work at the moment #7730
[[ $(nix eval "$rootFlake#y") = 6 ]] || true
# This will force refresh flake.lock with changes from sub/flake.lock
nix flake update --flake "$rootFlake"
[[ $(nix eval "$rootFlake#y") = 6 ]]

View file

@ -108,3 +108,24 @@ EOF
[[ $(nix eval "$rootFlake#z") = 90 ]]
fi
# https://github.com/NixOS/nix/pull/10089#discussion_r2041984987
# https://github.com/NixOS/nix/issues/13018
mkdir -p "$TEST_ROOT/issue-13018/example"
(
cd "$TEST_ROOT/issue-13018"
git init
echo '{ outputs = _: { }; }' >flake.nix
cat >example/flake.nix <<EOF
{
inputs.parent.url = ../.;
outputs = { parent, ... }: builtins.seq parent { ok = null; };
}
EOF
git add -N .
cd example
# Important: the error does not trigger for an in-memory lock!
nix flake lock
# would fail:
nix eval .#ok
)