Merge branch 'master' of github.com:NixOS/nix into misc-ca

This commit is contained in:
Carlo Nucera 2020-07-17 11:06:54 -04:00
commit a395c12830
4 changed files with 49 additions and 44 deletions

3
shell.nix Normal file
View file

@ -0,0 +1,3 @@
(import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).shellNix

View file

@ -102,14 +102,15 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
percentDecode(std::string(match[6]))); percentDecode(std::string(match[6])));
} }
/* Check if 'url' is a path (either absolute or relative to
'baseDir'). If so, search upward to the root of the repo
(i.e. the directory containing .git). */
else if (std::regex_match(url, match, pathUrlRegex)) { else if (std::regex_match(url, match, pathUrlRegex)) {
std::string path = match[1]; std::string path = match[1];
if (!baseDir && !hasPrefix(path, "/")) std::string fragment = percentDecode(std::string(match[3]));
throw BadURL("flake reference '%s' is not an absolute path", url);
if (baseDir) {
/* Check if 'url' is a path (either absolute or relative
to 'baseDir'). If so, search upward to the root of the
repo (i.e. the directory containing .git). */
path = absPath(path, baseDir, true); path = absPath(path, baseDir, true);
if (!S_ISDIR(lstat(path).st_mode)) if (!S_ISDIR(lstat(path).st_mode))
@ -118,8 +119,6 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
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);
auto fragment = percentDecode(std::string(match[3]));
auto flakeRoot = path; auto flakeRoot = path;
std::string subdir; std::string subdir;
@ -154,6 +153,12 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
flakeRoot = dirOf(flakeRoot); flakeRoot = dirOf(flakeRoot);
} }
} else {
if (!hasPrefix(path, "/"))
throw BadURL("flake reference '%s' is not an absolute path", url);
path = canonPath(path);
}
fetchers::Attrs attrs; fetchers::Attrs attrs;
attrs.insert_or_assign("type", "path"); attrs.insert_or_assign("type", "path");
attrs.insert_or_assign("path", path); attrs.insert_or_assign("path", path);

View file

@ -395,7 +395,7 @@ struct CmdProfileInfo : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
} }
}; };
struct CmdProfileDiffClosures : virtual EvalCommand, virtual StoreCommand, MixDefaultProfile struct CmdProfileDiffClosures : virtual StoreCommand, MixDefaultProfile
{ {
std::string description() override std::string description() override
{ {

View file

@ -18,7 +18,6 @@ registry=$TEST_ROOT/registry.json
flake1Dir=$TEST_ROOT/flake1 flake1Dir=$TEST_ROOT/flake1
flake2Dir=$TEST_ROOT/flake2 flake2Dir=$TEST_ROOT/flake2
flake3Dir=$TEST_ROOT/flake3 flake3Dir=$TEST_ROOT/flake3
flake4Dir=$TEST_ROOT/flake4
flake5Dir=$TEST_ROOT/flake5 flake5Dir=$TEST_ROOT/flake5
flake6Dir=$TEST_ROOT/flake6 flake6Dir=$TEST_ROOT/flake6
flake7Dir=$TEST_ROOT/flake7 flake7Dir=$TEST_ROOT/flake7
@ -390,14 +389,12 @@ cat > $flake3Dir/flake.nix <<EOF
}; };
} }
EOF EOF
git -C $flake3Dir add flake.nix nix flake update $flake3Dir
git -C $flake3Dir add flake.nix flake.lock
git -C $flake3Dir commit -m 'Remove packages.xyzzy' git -C $flake3Dir commit -m 'Remove packages.xyzzy'
git -C $flake3Dir checkout master git -C $flake3Dir checkout master
# Test whether fuzzy-matching works for IsAlias # Test whether fuzzy-matching works for registry entries.
(! nix build -o $TEST_ROOT/result flake4/removeXyzzy#xyzzy)
# Test whether fuzzy-matching works for IsGit
(! nix build -o $TEST_ROOT/result flake4/removeXyzzy#xyzzy) (! nix build -o $TEST_ROOT/result flake4/removeXyzzy#xyzzy)
nix build -o $TEST_ROOT/result flake4/removeXyzzy#sth nix build -o $TEST_ROOT/result flake4/removeXyzzy#sth