Skip to content

Commit

Permalink
upgrade-nix: add --dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
LnL7 committed Aug 25, 2018
1 parent c651b7b commit 4143977
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/nix/upgrade-nix.cc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "command.hh"
#include "common-args.hh"
#include "store-api.hh"
#include "download.hh"
#include "eval.hh"
#include "attr-path.hh"

using namespace nix;

struct CmdUpgradeNix : StoreCommand
struct CmdUpgradeNix : MixDryRun, StoreCommand
{
Path profileDir;

Expand Down Expand Up @@ -61,21 +62,25 @@ struct CmdUpgradeNix : StoreCommand

{
Activity act(*logger, lvlInfo, actUnknown, fmt("downloading '%s'...", storePath));
store->ensurePath(storePath);
if (!dryRun)
store->ensurePath(storePath);
}

{
Activity act(*logger, lvlInfo, actUnknown, fmt("verifying that '%s' works...", storePath));
auto program = storePath + "/bin/nix-env";
auto s = runProgram(program, false, {"--version"});
if (s.find("Nix") == std::string::npos)
throw Error("could not verify that '%s' works", program);
if (!dryRun) {
auto program = storePath + "/bin/nix-env";
auto s = runProgram(program, false, {"--version"});
if (s.find("Nix") == std::string::npos)
throw Error("could not verify that '%s' works", program);
}
}

{
Activity act(*logger, lvlInfo, actUnknown, fmt("installing '%s' into profile '%s'...", storePath, profileDir));
runProgram(settings.nixBinDir + "/nix-env", false,
{"--profile", profileDir, "-i", storePath, "--no-sandbox"});
if (!dryRun)
runProgram(settings.nixBinDir + "/nix-env", false,
{"--profile", profileDir, "-i", storePath, "--no-sandbox"});
}
}

Expand Down

0 comments on commit 4143977

Please sign in to comment.