diff options
author | Nick Van den Broeck <nick.van.den.broeck666@gmail.com> | 2019-02-21 06:53:01 +0100 |
---|---|---|
committer | Nick Van den Broeck <nick.van.den.broeck666@gmail.com> | 2019-03-22 11:16:20 +0100 |
commit | d4ee8afd59cd7935f59b730c432cf58460af8a84 (patch) | |
tree | 42f09e66ed56a03508b1b1b55fc03f2e8d6abd88 /src/nix/flake.cc | |
parent | 6542de98c298b6dc268b358166bd2f5bea2cc230 (diff) |
Implemented --flake flag for nix build
Also fixed Eelco's PR comments
Diffstat (limited to 'src/nix/flake.cc')
-rw-r--r-- | src/nix/flake.cc | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 22e5b297c..6cef38936 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -34,7 +34,28 @@ struct CmdFlakeList : StoreCommand, MixEvalArgs } }; -struct CmdFlakeInfo : FlakeCommand, JsonFormattable +struct CmdFlakeUpdate : FlakeCommand +{ + std::string name() override + { + return "update"; + } + + std::string description() override + { + return "update flake lock file"; + } + + void run(nix::ref<nix::Store> store) override + { + auto evalState = std::make_shared<EvalState>(searchPath, store); + + if (flakeUri == "") flakeUri = absPath("./flake.nix"); + updateLockFile(*evalState, flakeUri); + } +}; + +struct CmdFlakeInfo : FlakeCommand, MixJSON { std::string name() override { @@ -50,7 +71,7 @@ struct CmdFlakeInfo : FlakeCommand, JsonFormattable { auto evalState = std::make_shared<EvalState>(searchPath, store); nix::Flake flake = nix::getFlake(*evalState, FlakeRef(flakeUri)); - if (jsonFormatting) { + if (json) { nlohmann::json j; j["location"] = flake.path; j["description"] = flake.description; @@ -65,7 +86,9 @@ struct CmdFlakeInfo : FlakeCommand, JsonFormattable struct CmdFlake : virtual MultiCommand, virtual Command { CmdFlake() - : MultiCommand({make_ref<CmdFlakeList>(), make_ref<CmdFlakeInfo>()}) + : MultiCommand({make_ref<CmdFlakeList>() + , make_ref<CmdFlakeInfo>() + , make_ref<CmdFlakeUpdate>()}) { } |