mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
upgrade-nix: add --dry-run
This commit is contained in:
parent
c651b7bdc9
commit
414397759a
1 changed files with 13 additions and 8 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "command.hh"
|
#include "command.hh"
|
||||||
|
#include "common-args.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "download.hh"
|
#include "download.hh"
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
|
@ -6,7 +7,7 @@
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
struct CmdUpgradeNix : StoreCommand
|
struct CmdUpgradeNix : MixDryRun, StoreCommand
|
||||||
{
|
{
|
||||||
Path profileDir;
|
Path profileDir;
|
||||||
|
|
||||||
|
@ -61,19 +62,23 @@ struct CmdUpgradeNix : StoreCommand
|
||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlInfo, actUnknown, fmt("downloading '%s'...", storePath));
|
Activity act(*logger, lvlInfo, actUnknown, fmt("downloading '%s'...", storePath));
|
||||||
|
if (!dryRun)
|
||||||
store->ensurePath(storePath);
|
store->ensurePath(storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlInfo, actUnknown, fmt("verifying that '%s' works...", storePath));
|
Activity act(*logger, lvlInfo, actUnknown, fmt("verifying that '%s' works...", storePath));
|
||||||
|
if (!dryRun) {
|
||||||
auto program = storePath + "/bin/nix-env";
|
auto program = storePath + "/bin/nix-env";
|
||||||
auto s = runProgram(program, false, {"--version"});
|
auto s = runProgram(program, false, {"--version"});
|
||||||
if (s.find("Nix") == std::string::npos)
|
if (s.find("Nix") == std::string::npos)
|
||||||
throw Error("could not verify that '%s' works", program);
|
throw Error("could not verify that '%s' works", program);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Activity act(*logger, lvlInfo, actUnknown, fmt("installing '%s' into profile '%s'...", storePath, profileDir));
|
Activity act(*logger, lvlInfo, actUnknown, fmt("installing '%s' into profile '%s'...", storePath, profileDir));
|
||||||
|
if (!dryRun)
|
||||||
runProgram(settings.nixBinDir + "/nix-env", false,
|
runProgram(settings.nixBinDir + "/nix-env", false,
|
||||||
{"--profile", profileDir, "-i", storePath, "--no-sandbox"});
|
{"--profile", profileDir, "-i", storePath, "--no-sandbox"});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue