diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-10-14T10·07+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-10-14T10·08+0200 |
commit | 2c1711ae33c0824570dab4651c5aefd273e8eba6 (patch) | |
tree | 68ff7e352a8e8bfedd5d61d8bcfacc72f0626cee /scripts | |
parent | c6849e2dee743d9a4aca30842244d956ddcd25c3 (diff) |
nix-channel: Add --rollback flag
Fixes #368.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/nix-channel.in | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 8e07821c43c7..b8c93df18c32 100755 --- a/scripts/nix-channel.in +++ b/scripts/nix-channel.in @@ -199,6 +199,20 @@ while (scalar @ARGV) { last; } + elsif ($arg eq "--rollback") { + die "$0: ‘--rollback’ has at most one argument\n" if scalar @ARGV > 1; + my $generation = shift @ARGV; + my @args = ("$Nix::Config::binDir/nix-env", "--profile", $profile); + if (defined $generation) { + die "invalid channel generation number ‘$generation’" unless $generation =~ /^[0-9]+$/; + push @args, "--switch-generation", $generation; + } else { + push @args, "--rollback"; + } + system(@args) == 0 or exit 1; + last; + } + elsif ($arg eq "--help") { exec "man nix-channel" or die; } |