[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
253/376: nix-channel: Add --rollback flag
From: |
Ludovic Courtès |
Subject: |
253/376: nix-channel: Add --rollback flag |
Date: |
Wed, 28 Jan 2015 22:05:25 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 2c1711ae33c0824570dab4651c5aefd273e8eba6
Author: Eelco Dolstra <address@hidden>
Date: Tue Oct 14 12:07:56 2014 +0200
nix-channel: Add --rollback flag
Fixes #368.
---
doc/manual/command-ref/nix-channel.xml | 55 +++++++++++++++++++++++++++++++-
scripts/nix-channel.in | 14 ++++++++
2 files changed, 68 insertions(+), 1 deletions(-)
diff --git a/doc/manual/command-ref/nix-channel.xml
b/doc/manual/command-ref/nix-channel.xml
index 63ecba8..c4cc04c 100644
--- a/doc/manual/command-ref/nix-channel.xml
+++ b/doc/manual/command-ref/nix-channel.xml
@@ -24,6 +24,7 @@
<arg choice='plain'><option>--remove</option>
<replaceable>url</replaceable></arg>
<arg choice='plain'><option>--list</option></arg>
<arg choice='plain'><option>--update</option> <arg
rep='repeat'><replaceable>names</replaceable></arg></arg>
+ <arg choice='plain'><option>--rollback</option> <arg
choice='opt'><replaceable>generation</replaceable></arg></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
@@ -80,6 +81,14 @@ condition="manual">See also <xref linkend="sec-channels"
</varlistentry>
+ <varlistentry><term><option>--rollback</option>
[<replaceable>generation</replaceable>]</term>
+
+ <listitem><para>Reverts the previous call to <command>nix-channel
+ --update</command>. Optionally, you can specify a specific channel
+ generation number to restore.</para></listitem>
+
+ </varlistentry>
+
</variablelist>
</para>
@@ -104,10 +113,54 @@ respectively.</para>
<para>To subscribe to the Nixpkgs channel and install the GNU Hello
package:</para>
<screen>
-$ nix-channel --add http://nixos.org/channels/nixpkgs-unstable
+$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable
$ nix-channel --update
$ nix-env -iA nixpkgs.hello</screen>
+<para>You can revert channel updates using <option>--rollback</option>:</para>
+
+<screen>
+$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.nixpkgsVersion'
+"14.04.527.0e935f1"
+
+$ nix-channel --rollback
+switching from generation 483 to 482
+
+$ nix-instantiate --eval -E '(import <nixpkgs> {}).lib.nixpkgsVersion'
+"14.04.526.dbadfad"
+</screen>
+
+</refsection>
+
+<refsection><title>Files</title>
+
+<variablelist>
+
+
<varlistentry><term><filename>/nix/var/nix/profiles/<replaceable>username</replaceable>/channels</filename></term>
+
+ <listitem><para><command>nix-channel</command> uses a
+ <command>nix-env</command> profile to keep track of previous
+ versions of the subscribed channels. Every time you run
+ <command>nix-channel --update</command>, a new channel generation
+ (that is, a symlink to the channel Nix expressions in the Nix store)
+ is created. This enables <command>nix-channel --rollback</command>
+ to revert to previous versions.</para></listitem>
+
+ </varlistentry>
+
+ <varlistentry><term><filename>~/.nix-defexpr/channels</filename></term>
+
+ <listitem><para>This is a symlink to
+
<filename>/nix/var/nix/profiles/<replaceable>username</replaceable>/channels</filename>.
It
+ ensures that <command>nix-env</command> can find your channels. In
+ a multi-user installation, you may also have
+ <filename>~/.nix-defexpr/channels_root</filename>, which links to
+ the channels of the root user.</para></listitem>
+
+ </varlistentry>
+
+</variablelist>
+
</refsection>
</refentry>
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 8e07821..b8c93df 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;
}
- 301/376: 'build-cache-failures' -> 'build-cache-failure' in nix.conf documentation., (continued)
- 301/376: 'build-cache-failures' -> 'build-cache-failure' in nix.conf documentation., Ludovic Courtès, 2015/01/28
- 275/376: Revert "Revert "Revert "Temporarily disable darwin builds while hydra's darwin is borked""", Ludovic Courtès, 2015/01/28
- 302/376: Don't claim FreeBSD support, Ludovic Courtès, 2015/01/28
- 274/376: Don't pull in git when doing a nix-shell, Ludovic Courtès, 2015/01/28
- 247/376: mkList: Scrub better, Ludovic Courtès, 2015/01/28
- 248/376: Improved error message when encountering unsupported file types, Ludovic Courtès, 2015/01/28
- 295/376: nix-daemon: Call exit(), not _exit(), Ludovic Courtès, 2015/01/28
- 242/376: Add primop ‘attrValues’, Ludovic Courtès, 2015/01/28
- 254/376: nix-store -q: Check for conflicting flags, Ludovic Courtès, 2015/01/28
- 265/376: Merge pull request #380 from shlevy/temp-disable-darwin, Ludovic Courtès, 2015/01/28
- 253/376: nix-channel: Add --rollback flag,
Ludovic Courtès <=
- 289/376: Document functors, Ludovic Courtès, 2015/01/28
- 259/376: Export realiseContext in libnixexpr, Ludovic Courtès, 2015/01/28
- 284/376: SSH.pm: Print a friendlier message if connecting fails, Ludovic Courtès, 2015/01/28
- 278/376: Typo, Ludovic Courtès, 2015/01/28
- 292/376: Add a test for the binary tarball installer, Ludovic Courtès, 2015/01/28
- 296/376: Disable vacuuming the DB after garbage collection, Ludovic Courtès, 2015/01/28
- 298/376: Fix bad operator, Ludovic Courtès, 2015/01/28
- 270/376: Revert "Temporarily disable darwin builds while hydra's darwin is borked", Ludovic Courtès, 2015/01/28
- 283/376: Doh, Ludovic Courtès, 2015/01/28
- 300/376: import derivation: cleanup, Ludovic Courtès, 2015/01/28