Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix upgrade-nix: make the source URL an option #9333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/libstore/globals.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,16 @@ public:
true, // document default
Xp::ConfigurableImpureEnv
};

Setting<std::string> upgradeNixStorePathUrl{
this,
"https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix",
"upgrade-nix-store-path-url",
R"(
Used by `nix upgrade-nix`, the URL of the file that contains the
store paths of the latest Nix release.
)"
};
};


Expand Down
7 changes: 3 additions & 4 deletions src/nix/upgrade-nix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ using namespace nix;
struct CmdUpgradeNix : MixDryRun, StoreCommand
{
Path profileDir;
std::string storePathsUrl = "https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix";

CmdUpgradeNix()
{
Expand All @@ -30,7 +29,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
.longName = "nix-store-paths-url",
.description = "The URL of the file that contains the store paths of the latest Nix release.",
.labels = {"url"},
.handler = {&storePathsUrl}
.handler = {&(std::string&) settings.upgradeNixStorePathUrl}
});
}

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

std::string description() override
{
return "upgrade Nix to the stable version declared in Nixpkgs";
return "upgrade Nix to the latest stable version";
}

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

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

auto state = std::make_unique<EvalState>(SearchPath{}, store);
Expand Down
6 changes: 4 additions & 2 deletions src/nix/upgrade-nix.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ R""(

# Description

This command upgrades Nix to the stable version declared in Nixpkgs.
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)
This command upgrades Nix to the stable version.

By default, the latest stable version is defined by Nixpkgs, in
[nix-fallback-paths.nix](https://github.com/NixOS/nixpkgs/raw/master/nixos/modules/installer/tools/nix-fallback-paths.nix)
and updated manually. It may not always be the latest tagged release.

By default, it locates the directory containing the `nix` binary in the `$PATH`
Expand Down
Loading