mirror of
https://github.com/NixOS/nix.git
synced 2024-11-26 08:42:30 +00:00
Don't fail if a flakeref directly points to the flake.nix
Just warn and redirect it to the parent directory
This commit is contained in:
parent
11a1dcc43b
commit
2f0bc6373c
@ -102,8 +102,18 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
|
|||||||
|
|
||||||
if (isFlake) {
|
if (isFlake) {
|
||||||
|
|
||||||
if (!S_ISDIR(lstat(path).st_mode))
|
if (!S_ISDIR(lstat(path).st_mode)) {
|
||||||
throw BadURL("path '%s' is not a flake (because it's not a directory)", path);
|
if (baseNameOf(path) == "flake.nix") {
|
||||||
|
// Be gentle with people who accidentally write `/foo/bar/flake.nix` instead of `/foo/bar`
|
||||||
|
warn(
|
||||||
|
"Path '%s' should point at the directory containing the 'flake.nix' file, not the file itself. "
|
||||||
|
"Pretending that you meant '%s'"
|
||||||
|
, path, dirOf(path));
|
||||||
|
path = dirOf(path);
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user