diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-09-07 16:12:34 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-09-07 16:12:34 +0200 |
commit | e143ae471f32275a0ebbce996b1e481163f5fe33 (patch) | |
tree | 64b635e426abf0487eea754b72d3b6f6c55a3b17 /nix-script-channel-checkout-generation.sh | |
parent | e09781c6b551689dd569f8bd473210e32cdbe6e9 (diff) | |
parent | d0fb9648ce12a47b8490626df449b2bf6aa4ab16 (diff) |
Merge pull request #17 from matthiasbeyer/add-channel-tools
Add channel tools
Diffstat (limited to 'nix-script-channel-checkout-generation.sh')
-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..ba0db5e --- /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 "channel" "checkout-generation [-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 + |