diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-01-29 14:57:57 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-01-29 18:41:25 +0100 |
commit | f68bed7f67d9acc13ebe38e6f5aa8a641f6e557d (patch) | |
tree | 1370862f1228da0d524c64eca129956691232762 /src/libexpr/flake/lockfile.cc | |
parent | e53c89a64388ba2dc39f956c8f63620d28cc32af (diff) |
Add flag --override-input to override specific lock file entries
E.g.
$ nix flake update ~/Misc/eelco-configurations/hagbard \
--override-input 'dwarffs/nixpkgs' ../my-nixpkgs
overrides the 'nixpkgs' input of the 'dwarffs' input of the top-level
flake.
Fixes #2837.
Diffstat (limited to 'src/libexpr/flake/lockfile.cc')
-rw-r--r-- | src/libexpr/flake/lockfile.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc index a7291db5b..b92ffb70e 100644 --- a/src/libexpr/flake/lockfile.cc +++ b/src/libexpr/flake/lockfile.cc @@ -1,5 +1,6 @@ #include "lockfile.hh" #include "store-api.hh" +#include "fetchers/regex.hh" #include <nlohmann/json.hpp> @@ -104,4 +105,20 @@ void LockFile::write(const Path & path) const writeFile(path, fmt("%s\n", *this)); } +InputPath parseInputPath(std::string_view s) +{ + InputPath path; + + for (auto & elem : tokenizeString<std::vector<std::string>>(s, "/")) { + if (!std::regex_match(elem, fetchers::flakeIdRegex)) + throw Error("invalid flake input path element '%s'", elem); + path.push_back(elem); + } + + if (path.empty()) + throw Error("flake input path is empty"); + + return path; +} + } |