Skip to content

Commit fd5a4a8

Browse files
committed
nix upgrade-nix: make the source URL an option
This new option enables organizations to more easily manage their Nix fleet's deployment, and ensure a consistent and planned rollout of Nix upgrades.
1 parent 458e511 commit fd5a4a8

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/libstore/globals.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,16 @@ public:
10841084
true, // document default
10851085
Xp::ConfigurableImpureEnv
10861086
};
1087+
1088+
Setting<std::string> upgradeNixStorePathUrl{
1089+
this,
1090+
"https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix",
1091+
"upgrade-nix-store-path-url",
1092+
R"(
1093+
Used by `nix upgrade-nix`, the URL of the file that contains the
1094+
store paths of the latest Nix release.
1095+
)"
1096+
};
10871097
};
10881098

10891099

src/nix/upgrade-nix.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ using namespace nix;
1414
struct CmdUpgradeNix : MixDryRun, StoreCommand
1515
{
1616
Path profileDir;
17-
std::string storePathsUrl = "https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix";
1817

1918
CmdUpgradeNix()
2019
{
@@ -30,7 +29,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
3029
.longName = "nix-store-paths-url",
3130
.description = "The URL of the file that contains the store paths of the latest Nix release.",
3231
.labels = {"url"},
33-
.handler = {&storePathsUrl}
32+
.handler = {&(std::string&) settings.upgradeNixStorePathUrl}
3433
});
3534
}
3635

@@ -44,7 +43,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
4443

4544
std::string description() override
4645
{
47-
return "upgrade Nix to the stable version declared in Nixpkgs";
46+
return "upgrade Nix to the latest stable version";
4847
}
4948

5049
std::string doc() override
@@ -145,7 +144,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
145144
Activity act(*logger, lvlInfo, actUnknown, "querying latest Nix version");
146145

147146
// FIXME: use nixos.org?
148-
auto req = FileTransferRequest(storePathsUrl);
147+
auto req = FileTransferRequest((std::string&) settings.upgradeNixStorePathUrl);
149148
auto res = getFileTransfer()->download(req);
150149

151150
auto state = std::make_unique<EvalState>(SearchPath{}, store);

src/nix/upgrade-nix.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ R""(
1616

1717
# Description
1818

19-
This command upgrades Nix to the stable version declared in Nixpkgs.
20-
This stable version is defined in [nix-fallback-paths.nix](https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix)
19+
This command upgrades Nix to the stable version.
20+
21+
By default, the latest stable version is defined by Nixpkgs, in
22+
[nix-fallback-paths.nix](https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix)
2123
and updated manually. It may not always be the latest tagged release.
2224

2325
By default, it locates the directory containing the `nix` binary in the `$PATH`

0 commit comments

Comments
 (0)