mirror of
https://github.com/NixOS/nix
synced 2025-07-13 17:10:47 +02:00
Merge remote-tracking branch 'origin/master' into relative-flakes
This commit is contained in:
commit
550fe889ee
33 changed files with 142 additions and 42 deletions
|
@ -76,3 +76,21 @@ git -C "$rootRepo" commit -m "Add flake.nix"
|
|||
|
||||
storePath=$(nix flake metadata --json "$rootRepo?submodules=1" | jq -r .path)
|
||||
[[ -e "$storePath/submodule" ]]
|
||||
|
||||
# The root repo may use the submodule repo as an input
|
||||
# through the relative path. This may change in the future;
|
||||
# see: https://discourse.nixos.org/t/57783 and #9708.
|
||||
cat > "$rootRepo"/flake.nix <<EOF
|
||||
{
|
||||
inputs.subRepo.url = "git+file:./submodule";
|
||||
outputs = { ... }: { };
|
||||
}
|
||||
EOF
|
||||
git -C "$rootRepo" add flake.nix
|
||||
git -C "$rootRepo" commit -m "Add subRepo input"
|
||||
(
|
||||
cd "$rootRepo"
|
||||
# The submodule must be locked to the relative path,
|
||||
# _not_ the absolute path:
|
||||
[[ $(nix flake metadata --json | jq -r .locks.nodes.subRepo.locked.url) = "file:./submodule" ]]
|
||||
)
|
||||
|
|
|
@ -97,6 +97,9 @@ nix build -o "$TEST_ROOT/result" flake1
|
|||
|
||||
nix build -o "$TEST_ROOT/result" "$flake1Dir"
|
||||
nix build -o "$TEST_ROOT/result" "git+file://$flake1Dir"
|
||||
(cd "$flake1Dir" && nix build -o "$TEST_ROOT/result" ".")
|
||||
(cd "$flake1Dir" && nix build -o "$TEST_ROOT/result" "path:.")
|
||||
(cd "$flake1Dir" && nix build -o "$TEST_ROOT/result" "git+file:.")
|
||||
|
||||
# Test explicit packages.default.
|
||||
nix build -o "$TEST_ROOT/result" "$flake1Dir#default"
|
||||
|
@ -106,6 +109,15 @@ nix build -o "$TEST_ROOT/result" "git+file://$flake1Dir#default"
|
|||
nix build -o "$TEST_ROOT/result" "$flake1Dir?ref=HEAD#default"
|
||||
nix build -o "$TEST_ROOT/result" "git+file://$flake1Dir?ref=HEAD#default"
|
||||
|
||||
# Check that relative paths are allowed for git flakes.
|
||||
# This may change in the future once git submodule support is refined.
|
||||
# See: https://discourse.nixos.org/t/57783 and #9708.
|
||||
(
|
||||
# This `cd` should not be required and is indicative of aforementioned bug.
|
||||
cd "$flake1Dir/.."
|
||||
nix build -o "$TEST_ROOT/result" "git+file:./$(basename "$flake1Dir")"
|
||||
)
|
||||
|
||||
# Check that store symlinks inside a flake are not interpreted as flakes.
|
||||
nix build -o "$flake1Dir/result" "git+file://$flake1Dir"
|
||||
nix path-info "$flake1Dir/result"
|
||||
|
|
|
@ -31,5 +31,14 @@ echo 456 > "$flake1Dir"/x.nix
|
|||
|
||||
[[ $(nix eval --json "$flake2Dir#x" --override-input flake1 "$TEST_ROOT/flake1") = 456 ]]
|
||||
|
||||
# Dirty overrides require --allow-dirty-locks.
|
||||
expectStderr 1 nix flake lock "$flake2Dir" --override-input flake1 "$TEST_ROOT/flake1" |
|
||||
grepQuiet "cannot write lock file.*because it has an unlocked input"
|
||||
grepQuiet "Will not write lock file.*because it has an unlocked input"
|
||||
|
||||
nix flake lock "$flake2Dir" --override-input flake1 "$TEST_ROOT/flake1" --allow-dirty-locks
|
||||
|
||||
# Using a lock file with a dirty lock requires --allow-dirty-locks as well.
|
||||
expectStderr 1 nix eval "$flake2Dir#x" |
|
||||
grepQuiet "Lock file contains unlocked input"
|
||||
|
||||
[[ $(nix eval "$flake2Dir#x" --allow-dirty-locks) = 456 ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue