aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
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