diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-05-28 21:21:09 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-09-07 16:11:45 +0200 |
commit | 9140a5cfe32a2fc57649f9436a6c5c0ee4b176ee (patch) | |
tree | 4c2ca58e4f7bd9a14b7b207177acda32e16049d6 | |
parent | a82ae9096fefc8bed71c002b8e99a930e2bc7fb4 (diff) |
Add script for checking out a generation
-rwxr-xr-x | nix-script-channel-checkout-generation.sh | 45 |
1 files changed, 45 insertions, 0 deletions
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 <<EOS + $(help_synopsis "${BASH_SOURCE[0]}" "[-h] [-g <n>]") + + -g <n> 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 + |