diff options
author | pennae <82953136+pennae@users.noreply.github.com> | 2022-03-10 00:32:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 00:32:34 +0000 |
commit | f2603e9c92947a0e0c01fc34e754270f46c63790 (patch) | |
tree | 895ae7325d6ddb9846b00069fccb05ba18d9b3f3 /src/nix | |
parent | 417aaf4ff7ac1ca501c5a460775fa25d8e078c8a (diff) | |
parent | 4d98143914120d0163f5c50f30ce8a5289433f8f (diff) |
Merge branch 'master' into lto
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/flake.cc | 11 | ||||
-rw-r--r-- | src/nix/repl.cc | 2 | ||||
-rw-r--r-- | src/nix/store-delete.cc | 5 | ||||
-rw-r--r-- | src/nix/store-gc.cc | 5 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 144f8f886..47a380238 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -706,9 +706,14 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand auto [cursor, attrPath] = installable.getCursor(*evalState); - auto templateDir = cursor->getAttr("path")->getString(); - - assert(store->isInStore(templateDir)); + auto templateDirAttr = cursor->getAttr("path"); + auto templateDir = templateDirAttr->getString(); + + if (!store->isInStore(templateDir)) + throw TypeError( + "'%s' was not found in the Nix store\n" + "If you've set '%s' to a string, try using a path instead.", + templateDir, templateDirAttr->getAttrPathStr()); std::vector<Path> files; diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 5c0d44c68..3a51a13e6 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -800,7 +800,7 @@ std::ostream & NixRepl::printValue(std::ostream & str, Value & v, unsigned int m else printStringValue(str, i.first.c_str()); str << " = "; - if (seen.find(i.second) != seen.end()) + if (seen.count(i.second)) str << "«repeated»"; else try { diff --git a/src/nix/store-delete.cc b/src/nix/store-delete.cc index e4a3cb554..aa7a8b12f 100644 --- a/src/nix/store-delete.cc +++ b/src/nix/store-delete.cc @@ -2,6 +2,7 @@ #include "common-args.hh" #include "shared.hh" #include "store-api.hh" +#include "gc-store.hh" using namespace nix; @@ -32,12 +33,14 @@ struct CmdStoreDelete : StorePathsCommand void run(ref<Store> store, std::vector<StorePath> && storePaths) override { + auto & gcStore = requireGcStore(*store); + for (auto & path : storePaths) options.pathsToDelete.insert(path); GCResults results; PrintFreed freed(true, results); - store->collectGarbage(options, results); + gcStore.collectGarbage(options, results); } }; diff --git a/src/nix/store-gc.cc b/src/nix/store-gc.cc index a2d74066e..21718dc0c 100644 --- a/src/nix/store-gc.cc +++ b/src/nix/store-gc.cc @@ -2,6 +2,7 @@ #include "common-args.hh" #include "shared.hh" #include "store-api.hh" +#include "gc-store.hh" using namespace nix; @@ -33,10 +34,12 @@ struct CmdStoreGC : StoreCommand, MixDryRun void run(ref<Store> store) override { + auto & gcStore = requireGcStore(*store); + options.action = dryRun ? GCOptions::gcReturnDead : GCOptions::gcDeleteDead; GCResults results; PrintFreed freed(options.action == GCOptions::gcDeleteDead, results); - store->collectGarbage(options, results); + gcStore.collectGarbage(options, results); } }; |