diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-06-19 15:16:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-19 15:16:22 +0200 |
commit | b651e1fd17a2fda80dfc861231922b468180077b (patch) | |
tree | 44b18beae699386a0355072816e9e2b58244fc3a | |
parent | 9f1d43384da1113f4db2b5010fe57a9f9c16bca3 (diff) | |
parent | ec6860cf411206d4a056250f73544c10970a9dc0 (diff) |
Merge pull request #121 from matthiasbeyer/tag-with-channel
Tag with channel
-rw-r--r-- | example.rc | 5 | ||||
-rwxr-xr-x | nix-script | 2 | ||||
-rwxr-xr-x | nix-script-channel-update.sh | 19 | ||||
-rwxr-xr-x | nix-script-channel.sh | 4 | ||||
-rwxr-xr-x | nix-script-switch.sh | 18 | ||||
-rw-r--r-- | nix-utils.sh | 7 |
6 files changed, 52 insertions, 3 deletions
@@ -78,3 +78,8 @@ RC_UPD_PUSH=0 # RC_UPD_PUSH_REMOTE="github" +# +# Channel name +# +RC_CHANNEL_NAME="unstable" + @@ -146,4 +146,4 @@ SCRIPT_ARGS=$(shift_n $SHIFT_ARGS $*) # execute the script with its arguments # stdout "Calling: '$SCRIPT $SCRIPT_ARGS'" -RC_CONFIG=$RC_CONFIG RC_NIXPKGS=$RC_NIXPKGS exec bash $SCRIPT $SCRIPT_ARGS +RC=$RC RC_CONFIG=$RC_CONFIG RC_NIXPKGS=$RC_NIXPKGS exec bash $SCRIPT $SCRIPT_ARGS diff --git a/nix-script-channel-update.sh b/nix-script-channel-update.sh index 505e4b0..4ad8720 100755 --- a/nix-script-channel-update.sh +++ b/nix-script-channel-update.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh +[[ -f "$RC" ]] && { dbg "Config file found. Sourcing: '$RC'"; source $RC; } 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> + -n | Add channel name (from config) in the tag name, currently: $RC_CHANNEL_NAME -w <cfgdir> | Alternative config dir, default: $RC_CONFIG -n | DON'T include hostname in tag name -h | Show this help and exit @@ -16,6 +18,7 @@ EOS } TAG_NAME="" +ADD_CHANNEL_NAME=0 CONFIG=$RC_CONFIG HOST="$(hostname)" @@ -27,6 +30,11 @@ do dbg "TAG_NAME = $TAG_NAME" ;; + n) + ADD_CHANNEL_NAME=1 + dbg "ADD_CHANNEL_NAME = $ADD_CHANNEL_NAME" + ;; + w) CONFIG=$OPTARG dbg "CONFIG = $CONFIG" @@ -61,6 +69,17 @@ then stdout "Tag name: '$TAG_NAME'" fi +if [[ $ADD_CHANNEL_NAME -eq 1 ]]; then + [[ -z "$RC_CHANNEL_NAME" ]] && \ + stderr "RC SETTING MISSING: RC_CHANNEL_NAME" && exit 1 + + dbg "Add the channel name in the tag" + TAG_NAME="${TAG_NAME}-${RC_CHANNEL_NAME}" + dbg "TAG_NAME = ${TAG_NAME}" +else + dbg "Do not add the channel name in the tag" +fi + stdout "Resetting sudo password" sudo -k diff --git a/nix-script-channel.sh b/nix-script-channel.sh index 6a24eca..d0880ba 100755 --- a/nix-script-channel.sh +++ b/nix-script-channel.sh @@ -51,5 +51,7 @@ stdout "SCRIPT = $SCRIPT" stdout "Parsing args for '$1'" SCRIPT_ARGS=$(echo $* | sed -r "s/(.*)$1(.*)/\2/") +[[ -f "$RC" ]] && { dbg "Config file found. Sourcing: '$RC'"; source $RC; } + stdout "Calling: '$SCRIPT $SCRIPT_ARGS'" -RC_CONFIG=$RC_CONFIG RC_NIXPKGS=$RC_NIXPKGS exec bash $SCRIPT $SCRIPT_ARGS +RC=$RC RC_CONFIG=$RC_CONFIG RC_NIXPKGS=$RC_NIXPKGS exec bash $SCRIPT $SCRIPT_ARGS diff --git a/nix-script-switch.sh b/nix-script-switch.sh index e91fe8c..7fc3b9c 100755 --- a/nix-script-switch.sh +++ b/nix-script-switch.sh @@ -22,6 +22,8 @@ usage() { -t <tagname> Custom tag name + -C Append channel generation in tag (<tag>-channel-<gen>) + -p [<pkgs>] Generate the switch tag in the nixpkgs at <pkgs> as well. (default: '$RC_NIXPKGS') @@ -78,6 +80,7 @@ COMMAND=switch ARGS= WD=$RC_CONFIG TAG_NAME= +APPEND_CHANNEL_GEN= HOSTNAME="$(hostname)" TAG_NIXPKGS=0 NIXPKGS=$RC_NIXPKGS @@ -89,7 +92,7 @@ DONT_BUILD= QUIET=1 USE_ALTERNATIVE_SOURCE_NIXPKGS=0 -while getopts "c:w:t:nbp:f:qs:r:h" OPTION +while getopts "c:w:t:Cnbp:f:qs:r:h" OPTION do case $OPTION in c) @@ -107,6 +110,11 @@ do dbg "TAG_NAME = $TAG_NAME" ;; + C) + APPEND_CHANNEL_GEN=1 + dbg "APPEND_CHANNEL_GEN = $APPEND_CHANNEL_GEN" + ;; + n) HOSTNAME="" dbg "HOSTNAME = $HOSTNAME" @@ -207,6 +215,14 @@ then fi fi +if [[ $APPEND_CHANNEL_GEN -eq 1 ]]; then + dbg "Appending channel generation to tag name" + TAG_NAME="${TAG_NAME}-channel-$(current_channel_generation)" + dbg "TAG_NAME = $TAG_NAME" +else + dbg "Not appending channel generation to tag name" +fi + if [[ "$COMMAND" =~ "build" ]] then stdout "Command is 'build'. Not generating config tag" diff --git a/nix-utils.sh b/nix-utils.sh index de1f76f..ff4824f 100644 --- a/nix-utils.sh +++ b/nix-utils.sh @@ -143,6 +143,13 @@ current_channel_generation() { } # +# Get the channel names +# +channel_names() { + sudo nix-channel --list | cut -d " " -f 1 +} + +# # Ask the user whether to continue or not # continue_question() { |