diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-07-28 18:44:10 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-07-28 18:44:10 +0200 |
commit | 9d91b7df35de760b509f1eab6f7cd61207088ef3 (patch) | |
tree | 29f3f1f56c859417ec2410896e1ccde1e50f83d7 | |
parent | c04c5f85e92e62a76c2e154a84c103dbd7656266 (diff) | |
parent | acd20400ca9432d91787020930f89a907d05256a (diff) |
Merge pull request #62 from matthiasbeyer/switch-add-nixpkgs-tagging
Add flag to generate a tag in the local nixpkgs
-rwxr-xr-x | nix-script-switch.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/nix-script-switch.sh b/nix-script-switch.sh index a901c82..8051e24 100755 --- a/nix-script-switch.sh +++ b/nix-script-switch.sh @@ -15,6 +15,7 @@ usage() { -w <path> Path to your configuration git directory -n DON'T include hostname in tag name -t <tagname> Custom tag name + -p <pkgs> Generate the switch tag in the nixpkgs at <pkgs> as well. -h Show this help and exit This command helps you rebuilding your system and keeping track @@ -49,8 +50,9 @@ ARGS= WD= TAG_NAME= HOSTNAME="$(hostname)" +NIXPKGS="" -while getopts "c:w:t:nh" OPTION +while getopts "c:w:t:np:h" OPTION do case $OPTION in c) @@ -71,6 +73,11 @@ do dbg "HOSTNAME disabled" ;; + p) + NIXPKGS=$OPTARG + stdout "NIXPKGS = $NIXPKGS" + ;; + h) usage exit 1 @@ -78,6 +85,25 @@ do esac done +# +# Function to generate the tag at $NIXPKGS as well +# +tag_nixpkgs() { + if [[ ! -d "$1" ]] + then + stderr "'$1' is not a directory, so can't be a nixpkgs clone" + return + fi + + commit=$(nixos-version | cut -d . -f 3 | cut -d " " -f 1) + + c_txt="Trying to create tag '$TAG_NAME' at '$1' on commit '$commit'" + continue_question "$c_txt" || return + + __git "$1" tag -a "$TAG_NAME" $commit || \ + stderr "Could not create tag in nixpkgs clone" +} + ARGS=$(echo $* | sed -r 's/(.*)(\-\-(.*)|$)/\2/') dbg "ARGS = $ARGS" @@ -108,6 +134,12 @@ then __git "$WD" tag -a "$TAG_NAME" + if [[ ! -z "$NIXPKGS" ]] + then + stdout "Trying to generate tag in $NIXPKGS" + tag_nixpkgs "$NIXPKGS" + fi + else stderr "Switching failed. Won't executing any further commands." exit $REBUILD_EXIT |