From 4ce68819b673eb4ec40fbd49d6e5e0aae1205e37 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 15 Jun 2016 10:33:52 +0200 Subject: Add flag (-C) to append channel generation to tag name --- nix-script-switch.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 Custom tag name + -C Append channel generation in tag (-channel-) + -p [] Generate the switch tag in the nixpkgs at 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" -- cgit v1.2.3 From 2ed22525d324f3dd6cb92f7f17c68ccf62d08969 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 15 Jun 2016 10:42:35 +0200 Subject: utils: Add function to get channel names --- nix-utils.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nix-utils.sh b/nix-utils.sh index de1f76f..ff4824f 100644 --- a/nix-utils.sh +++ b/nix-utils.sh @@ -142,6 +142,13 @@ current_channel_generation() { grep_generation "sudo nix-env -p /nix/var/nix/profiles/per-user/root/channels --list-generations" } +# +# Get the channel names +# +channel_names() { + sudo nix-channel --list | cut -d " " -f 1 +} + # # Ask the user whether to continue or not # -- cgit v1.2.3 From 022de6e384043e9a5b0a02edc2bf5e7fdfc80262 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 15 Jun 2016 10:42:55 +0200 Subject: Add setting for channel name to use in tags --- example.rc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/example.rc b/example.rc index 323446c..dac35de 100644 --- a/example.rc +++ b/example.rc @@ -78,3 +78,8 @@ RC_UPD_PUSH=0 # RC_UPD_PUSH_REMOTE="github" +# +# Channel name +# +RC_CHANNEL_NAME="unstable" + -- cgit v1.2.3 From c58fe70fa1de0015f8cf824a2eab53a7715b28b1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 15 Jun 2016 10:43:53 +0200 Subject: Add flag to add the channel name in the tag for channel-update tags --- nix-script-channel-update.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/nix-script-channel-update.sh b/nix-script-channel-update.sh index 505e4b0..ca4ef93 100755 --- a/nix-script-channel-update.sh +++ b/nix-script-channel-update.sh @@ -7,6 +7,7 @@ usage() { $(help_synopsis "channel" "update [-h] [-t ] [-w ] [-n]") -t | Name for the new tag, instead of nixos--channel- + -n | Add channel name (from config) in the tag name, currently: $RC_CHANNEL_NAME -w | Alternative config dir, default: $RC_CONFIG -n | DON'T include hostname in tag name -h | Show this help and exit @@ -16,6 +17,7 @@ EOS } TAG_NAME="" +ADD_CHANNEL_NAME=0 CONFIG=$RC_CONFIG HOST="$(hostname)" @@ -27,6 +29,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 +68,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 -- cgit v1.2.3 From ec6860cf411206d4a056250f73544c10970a9dc0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 19 Jun 2016 15:08:27 +0200 Subject: Ensure RC variable passthrough --- nix-script | 2 +- nix-script-channel-update.sh | 1 + nix-script-channel.sh | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/nix-script b/nix-script index 5bdfe15..5ff5fb4 100755 --- a/nix-script +++ b/nix-script @@ -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 ca4ef93..4ad8720 100755 --- a/nix-script-channel-update.sh +++ b/nix-script-channel-update.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash source $(dirname ${BASH_SOURCE[0]})/nix-utils.sh +[[ -f "$RC" ]] && { dbg "Config file found. Sourcing: '$RC'"; source $RC; } usage() { cat <