aboutsummaryrefslogtreecommitdiff
path: root/src/nix/upgrade-nix.cc
diff options
context:
space:
mode:
authorQyriad <qyriad@qyriad.me>2024-04-27 23:09:02 -0600
committerQyriad <qyriad@qyriad.me>2024-04-29 01:19:21 +0000
commitee5a1b5a4c53918c029316fb9c961bee58e7d518 (patch)
tree02de4b7f9faabdd4d53fb78c8f426408f2694e5b /src/nix/upgrade-nix.cc
parentaae12f5848d930abbf938f480f9851e77a234505 (diff)
nix3-upgrade-nix: allow manually specifying new nix
This allows manually specifying a store path for the new Nix that gets linked into Nix's profile. Change-Id: Ib71711ffb466febf4a6892e3fdbda644e053770d
Diffstat (limited to 'src/nix/upgrade-nix.cc')
-rw-r--r--src/nix/upgrade-nix.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc
index 4940d93f8..31a051246 100644
--- a/src/nix/upgrade-nix.cc
+++ b/src/nix/upgrade-nix.cc
@@ -21,6 +21,8 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
Path profileDir;
std::string storePathsUrl = "https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix";
+ std::optional<Path> overrideStorePath;
+
CmdUpgradeNix()
{
addFlag({
@@ -32,6 +34,13 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
});
addFlag({
+ .longName = "store-path",
+ .description = "A specific store path to upgrade Nix to",
+ .labels = {"store-path"},
+ .handler = {&overrideStorePath},
+ });
+
+ addFlag({
.longName = "nix-store-paths-url",
.description = "The URL of the file that contains the store paths of the latest Nix release.",
.labels = {"url"},
@@ -246,6 +255,14 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
/* Return the store path of the latest stable Nix. */
StorePath getLatestNix(ref<Store> store)
{
+ if (this->overrideStorePath) {
+ printTalkative(
+ "skipping Nix version query and using '%s' as latest Nix",
+ *this->overrideStorePath
+ );
+ return store->parseStorePath(*this->overrideStorePath);
+ }
+
Activity act(*logger, lvlInfo, actUnknown, "querying latest Nix version");
// FIXME: use nixos.org?