diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-09-08 11:34:12 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-09-11 15:45:36 +0200 |
commit | 436442a0f7c06682de2bd42764a8656e5aa8cb4c (patch) | |
tree | e71175ae1a8e74ff54acca9217c74d0d20c152d6 | |
parent | 45746cd685d15ff1270b297c1cf9ef2a2730d98f (diff) |
Add command to update channel and create a tag in the config for it
-rwxr-xr-x | nix-script-channel-update.sh | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/nix-script-channel-update.sh b/nix-script-channel-update.sh new file mode 100755 index 0000000..505e4b0 --- /dev/null +++ b/nix-script-channel-update.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh + +usage() { + cat <<EOS + $(help_synopsis "channel" "update [-h] [-t <name>] [-w <cfgdir>] [-n]") + + -t <name> | Name for the new tag, instead of nixos-<host>-channel-<num> + -w <cfgdir> | Alternative config dir, default: $RC_CONFIG + -n | DON'T include hostname in tag name + -h | Show this help and exit + +$(help_end) +EOS +} + +TAG_NAME="" +CONFIG=$RC_CONFIG +HOST="$(hostname)" + +while getopts "t:w:nh" OPTION +do + case $OPTION in + t) + TAG_NAME=$OPTARG + dbg "TAG_NAME = $TAG_NAME" + ;; + + w) + CONFIG=$OPTARG + dbg "CONFIG = $CONFIG" + ;; + + n) + HOST="" + dbg "HOST = $HOST" + ;; + + h) + usage + exit 0 + ;; + + *) + ;; + esac +done + +[[ -z "$CONFIG" ]] && \ + stderr "No configuration git directory." && \ + stderr "Won't do anything" && exit 1 + +stdout "Updating nix-channel" +explain sudo nix-channel --update +stdout "Ready with updating" + +if [[ -z "$NAME" ]] +then + TAG_NAME="nixos-$([[ ! -z "$HOST" ]] && echo "$HOST-")channel-$(current_channel_generation)" + stdout "Tag name: '$TAG_NAME'" +fi + +stdout "Resetting sudo password" +sudo -k + +stdout "Tagging '$CONFIG' repo with tag name '$TAG_NAME'" +__git "$CONFIG" tag $TAG_NAME + |