summaryrefslogtreecommitdiffstats
path: root/nix-script-switch.sh
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-07-05 16:41:07 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-07-05 16:41:07 +0200
commit23a0a8e51d973f0aaf1f66e6ded12970ddd312a1 (patch)
treebbdd642dfcf6b432f8b80289bf856e39171e2e35 /nix-script-switch.sh
parentc2d250d539edae760de31060dc1e379d4ed3c049 (diff)
parentaeb367f5cbeb755a0c6ebd87c3598eac2e13c75b (diff)
Merge pull request #29 from matthiasbeyer/add-switch_hostname
Add hostname in tagname
Diffstat (limited to 'nix-script-switch.sh')
-rwxr-xr-xnix-script-switch.sh16
1 files changed, 14 insertions, 2 deletions
diff --git a/nix-script-switch.sh b/nix-script-switch.sh
index 2290b33..4768f1e 100755
--- a/nix-script-switch.sh
+++ b/nix-script-switch.sh
@@ -14,6 +14,7 @@ usage() {
-c <command> Command for nixos-rebuild. See 'man nixos-rebuild'
-g <git cmd> Alternative git commit, defaults to 'tag -a'
-w <path> Path to your configuration git directory
+ -n Include hostname in tag name
-h Show this help and exit
Everything after a double dash (--) will be passed to nixos-rebuild as
@@ -30,8 +31,9 @@ ARGS=
WD=
TAG_NAME=
GIT_COMMAND=
+HOSTNAME=""
-while getopts "c:w:t:h" OPTION
+while getopts "c:w:t:nh" OPTION
do
case $OPTION in
c)
@@ -52,6 +54,11 @@ do
stdout "GIT_COMMAND = $GIT_COMMAND"
;;
+ n)
+ HOSTNAME=$(hostname)
+ stdout "HOSTNAME = $HOSTNAME"
+ ;;
+
h)
usage
exit 1
@@ -95,7 +102,12 @@ then
if [[ -z "$TAG_NAME" ]]
then
- TAG_NAME="nixos-$LASTGEN-$COMMAND"
+ if [[ -z "$HOSTNAME" ]]
+ then
+ TAG_NAME="nixos-$LASTGEN-$COMMAND"
+ else
+ TAG_NAME="nixos-$HOSTNAME-$LASTGEN-$COMMAND"
+ fi
fi
explain git --git-dir="$WD/.git" --work-tree="$WD" $GIT_COMMAND "$TAG_NAME"