aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-03-29 16:18:25 +0100
committerNick Van den Broeck <nick.van.den.broeck666@gmail.com>2019-04-09 09:51:42 +0200
commit3ec0c82fab94533807c5c3bb25df2b43d8339ed3 (patch)
tree094f7783c21fe0f6717e0f94ad8466cd7b8888e2 /src/nix
parent641db127be9df82fe4d51290120a8ba6d0b5f4fd (diff)
Fixed dependency resolution
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/build.cc10
-rw-r--r--src/nix/flake.cc25
2 files changed, 22 insertions, 13 deletions
diff --git a/src/nix/build.cc b/src/nix/build.cc
index f6908b0c0..226c21e9e 100644
--- a/src/nix/build.cc
+++ b/src/nix/build.cc
@@ -78,11 +78,11 @@ struct CmdBuild : MixDryRun, InstallablesCommand
}
}
- std::string flakeUri = "";
- if(updateLock)
- for (uint i = 0; i < installables.size(); i++)
- // if (auto flakeUri = installableToFlakeUri)
- updateLockFile(*evalState, flakeUri);
+ // std::string flakeUri = "";
+ // if(updateLock)
+ // for (uint i = 0; i < installables.size(); i++)
+ // // if (auto flakeUri = installableToFlakeUri)
+ // updateLockFile(*evalState, flakeUri, true);
}
};
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 07d31c45a..ff291aa80 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -5,6 +5,7 @@
#include "progress-bar.hh"
#include "eval.hh"
#include <nlohmann/json.hpp>
+#include <queue>
using namespace nix;
@@ -80,13 +81,21 @@ struct CmdFlakeDeps : FlakeCommand, MixJSON, StoreCommand, MixEvalArgs
FlakeRef flakeRef(flakeUri);
- Dependencies deps = resolveFlake(*evalState, flakeRef, true);
+ Dependencies deps = resolveFlake(*evalState, flakeRef, true, true);
- for (auto & flake : deps.flakes)
- printFlakeInfo(flake, json);
+ std::queue<Dependencies> todo;
+ todo.push(deps);
- for (auto & nonFlake : deps.nonFlakes)
- printNonFlakeInfo(nonFlake, json);
+ while (!todo.empty()) {
+ deps = todo.front();
+ todo.pop();
+
+ for (auto & nonFlake : deps.nonFlakeDeps)
+ printNonFlakeInfo(nonFlake, json);
+
+ for (auto & newDeps : deps.flakeDeps)
+ todo.push(newDeps);
+ }
}
};
@@ -107,7 +116,7 @@ struct CmdFlakeUpdate : StoreCommand, GitRepoCommand, MixEvalArgs
auto evalState = std::make_shared<EvalState>(searchPath, store);
if (gitPath == "") gitPath = absPath(".");
- updateLockFile(*evalState, gitPath);
+ updateLockFile(*evalState, gitPath, true);
}
};
@@ -126,7 +135,7 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON, MixEvalArgs, StoreCommand
void run(nix::ref<nix::Store> store) override
{
auto evalState = std::make_shared<EvalState>(searchPath, store);
- nix::Flake flake = nix::getFlake(*evalState, FlakeRef(flakeUri));
+ nix::Flake flake = nix::getFlake(*evalState, FlakeRef(flakeUri), true);
printFlakeInfo(flake, json);
}
};
@@ -220,7 +229,7 @@ struct CmdFlakePin : virtual Args, StoreCommand, MixEvalArgs
auto it = userRegistry.entries.find(flakeId);
if (it != userRegistry.entries.end()) {
FlakeRef oldRef = it->second.ref;
- it->second.ref = getFlake(*evalState, oldRef).ref;
+ it->second.ref = getFlake(*evalState, oldRef, true).ref;
// The 'ref' in 'flake' is immutable.
writeRegistry(userRegistry, userRegistryPath);
} else