From 9140a5cfe32a2fc57649f9436a6c5c0ee4b176ee Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 28 May 2015 21:21:09 +0200 Subject: Add script for checking out a generation --- nix-script-channel-checkout-generation.sh | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 nix-script-channel-checkout-generation.sh diff --git a/nix-script-channel-checkout-generation.sh b/nix-script-channel-checkout-generation.sh new file mode 100755 index 0000000..044e2d0 --- /dev/null +++ b/nix-script-channel-checkout-generation.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh + +usage() { + cat <]") + + -g Generation to checkout + -h Show this help and exit + +$(help_end) +EOS +} + +# no generation by now +GEN= + +while getopts "hg:" OPTION +do + case $OPTION in + g) + GEN=$OPTARG + stdout "GEN = $GEN" + ;; + h) + usage + exit 0 + ;; + + *) + ;; + esac +done + +[[ -z "$GEN" ]] && stderr "No generation number passed" && exit 1 + +CHANNELS=/nix/var/nix/profiles/per-user/root/channels + +stdout "Executing checkout. Password cache will be reset afterwards" +explain sudo nix-env -p $CHANNELS --switch-generation $GEN + +stdout "Resetting sudo password" +sudo -k + -- cgit v1.2.3