diff options
author | Alexander Bantyev <balsoft@balsoft.ru> | 2021-06-30 22:14:41 +0300 |
---|---|---|
committer | Alexander Bantyev <balsoft@balsoft.ru> | 2021-06-30 22:16:40 +0300 |
commit | 811f3e8605ce779830fa4770cd7ef3cda81afdf1 (patch) | |
tree | 7ac00d794afb930f2ef685f31b2367ff709cefd4 /src/nix | |
parent | 093ed4763615a73edb1e8567d2f41d55ff5aaa0c (diff) |
nix registry pin: add a way to pin to a custom locked
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/registry.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/nix/registry.cc b/src/nix/registry.cc index 4400cc8dc..ec80dc0bc 100644 --- a/src/nix/registry.cc +++ b/src/nix/registry.cc @@ -152,9 +152,11 @@ struct CmdRegistryPin : RegistryCommand, EvalCommand { std::string url; + std::string locked; + std::string description() override { - return "pin a flake to its current version in user flake registry"; + return "pin a flake to its current version in user flake registry or to the current version of a flake URI"; } std::string doc() override @@ -167,14 +169,27 @@ struct CmdRegistryPin : RegistryCommand, EvalCommand CmdRegistryPin() { expectArg("url", &url); + + expectArgs({ + .label = "locked", + .optional = true, + .handler = {&locked}, + .completer = {[&](size_t, std::string_view prefix) { + completeFlakeRef(getStore(), prefix); + }} + }); } void run(nix::ref<nix::Store> store) override { + if (locked.empty()) { + locked = url; + } auto registry = getRegistry(); auto ref = parseFlakeRef(url); + auto locked_ref = parseFlakeRef(locked); registry->remove(ref.input); - auto [tree, resolved] = ref.resolve(store).input.fetch(store); + auto [tree, resolved] = locked_ref.resolve(store).input.fetch(store); fetchers::Attrs extraAttrs; if (ref.subdir != "") extraAttrs["dir"] = ref.subdir; registry->add(ref.input, resolved, extraAttrs); |