mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-16 15:17:18 +02:00
Properly fail on flakerefs that don't point to a directory
Directly fail if a flakeref points to something that isn't a directory instead of falling back to the logic of trying to look up the hierarchy to find a valid flake root. Fix https://github.com/NixOS/nix/issues/9868
This commit is contained in:
parent
ba9b6b29b7
commit
11a1dcc43b
2 changed files with 4 additions and 4 deletions
|
@ -102,6 +102,9 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
|
||||||
|
|
||||||
if (isFlake) {
|
if (isFlake) {
|
||||||
|
|
||||||
|
if (!S_ISDIR(lstat(path).st_mode))
|
||||||
|
throw BadURL("path '%s' is not a flake (because it's not a directory)", path);
|
||||||
|
|
||||||
if (!allowMissing && !pathExists(path + "/flake.nix")){
|
if (!allowMissing && !pathExists(path + "/flake.nix")){
|
||||||
notice("path '%s' does not contain a 'flake.nix', searching up",path);
|
notice("path '%s' does not contain a 'flake.nix', searching up",path);
|
||||||
|
|
||||||
|
@ -124,9 +127,6 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
|
||||||
throw BadURL("could not find a flake.nix file");
|
throw BadURL("could not find a flake.nix file");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!S_ISDIR(lstat(path).st_mode))
|
|
||||||
throw BadURL("path '%s' is not a flake (because it's not a directory)", path);
|
|
||||||
|
|
||||||
if (!allowMissing && !pathExists(path + "/flake.nix"))
|
if (!allowMissing && !pathExists(path + "/flake.nix"))
|
||||||
throw BadURL("path '%s' is not a flake (because it doesn't contain a 'flake.nix' file)", path);
|
throw BadURL("path '%s' is not a flake (because it doesn't contain a 'flake.nix' file)", path);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ mkdir subdir
|
||||||
pushd subdir
|
pushd subdir
|
||||||
|
|
||||||
success=("" . .# .#test ../subdir ../subdir#test "$PWD")
|
success=("" . .# .#test ../subdir ../subdir#test "$PWD")
|
||||||
failure=("path:$PWD")
|
failure=("path:$PWD" "../simple.nix")
|
||||||
|
|
||||||
for i in "${success[@]}"; do
|
for i in "${success[@]}"; do
|
||||||
nix build $i || fail "flake should be found by searching up directories"
|
nix build $i || fail "flake should be found by searching up directories"
|
||||||
|
|
Loading…
Add table
Reference in a new issue