From b09b87321c058f691fcf64babe56620277b68e63 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 May 2013 14:55:36 -0400 Subject: [PATCH] nix-store --export: Export paths in topologically sorted order Fixes #118. --- src/libstore/store-api.hh | 2 +- src/nix-store/nix-store.cc | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 053bece7a..a82fe3221 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -328,7 +328,7 @@ Path addPermRoot(StoreAPI & store, const Path & storePath, /* Sort a set of paths topologically under the references relation. - If p refers to q, then p follows q in this list. */ + If p refers to q, then p preceeds q in this list. */ Paths topoSortPaths(StoreAPI & store, const PathSet & paths); diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 151ed97e4..5bd855836 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -694,7 +694,9 @@ static void opExport(Strings opFlags, Strings opArgs) else throw UsageError(format("unknown flag `%1%'") % *i); FdSink sink(STDOUT_FILENO); - exportPaths(*store, opArgs, sign, sink); + Paths sorted = topoSortPaths(*store, PathSet(opArgs.begin(), opArgs.end())); + reverse(sorted.begin(), sorted.end()); + exportPaths(*store, sorted, sign, sink); }