diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-09-27 10:57:11 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-09-27 12:47:39 +0200 |
commit | 4b2b15113196e403bc32ce0d7b4338971d7954a8 (patch) | |
tree | 98e3906b22fbdf9fdee599103486e8b26a284043 /src/libcmd | |
parent | a15e65eef0443a4d41b1a9e9b1504234dc5f5947 (diff) |
nix path-info -r: Don't duplicate the root paths
This fixes
$ nix path-info -r $(type -P ls)
/nix/store/vfilzcp8a467w3p0mp54ybq6bdzb8w49-coreutils-8.32
/nix/store/5d821pjgzb90lw4zbg6xwxs7llm335wr-libunistring-0.9.10
...
/nix/store/mrv4y369nw6hg4pw8d9p9bfdxj9pjw0x-acl-2.3.0
/nix/store/vfilzcp8a467w3p0mp54ybq6bdzb8w49-coreutils-8.32
Also, output the paths in topologically sorted order like we used to.
Diffstat (limited to 'src/libcmd')
-rw-r--r-- | src/libcmd/command.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libcmd/command.cc b/src/libcmd/command.cc index 2b9902677..0d61e12d0 100644 --- a/src/libcmd/command.cc +++ b/src/libcmd/command.cc @@ -120,7 +120,7 @@ void BuiltPathsCommand::run(ref<Store> store) // XXX: This only computes the store path closure, ignoring // intermediate realisations StorePathSet pathsRoots, pathsClosure; - for (auto & root: paths) { + for (auto & root : paths) { auto rootFromThis = root.outPaths(); pathsRoots.insert(rootFromThis.begin(), rootFromThis.end()); } @@ -140,12 +140,15 @@ StorePathsCommand::StorePathsCommand(bool recursive) void StorePathsCommand::run(ref<Store> store, BuiltPaths && paths) { - StorePaths storePaths; - for (auto& builtPath : paths) - for (auto& p : builtPath.outPaths()) - storePaths.push_back(p); + StorePathSet storePaths; + for (auto & builtPath : paths) + for (auto & p : builtPath.outPaths()) + storePaths.insert(p); - run(store, std::move(storePaths)); + auto sorted = store->topoSortPaths(storePaths); + std::reverse(sorted.begin(), sorted.end()); + + run(store, std::move(sorted)); } void StorePathCommand::run(ref<Store> store, std::vector<StorePath> && storePaths) |