From cbe184ccdc4fbf713bae56ffa1a4a70c44b17753 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 24 Sep 2015 19:30:06 +0200 Subject: Fetch commit hash before nixos-rebuild As described in #81, we should fetch the hash of the current HEAD before starting the nixos-rebuild run, as if this run takes a lot of time, the HEAD could have changed in between and so we would generate a tag on a wrong commit. --- nix-script-switch.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nix-script-switch.sh b/nix-script-switch.sh index 6848a57..bd26c76 100755 --- a/nix-script-switch.sh +++ b/nix-script-switch.sh @@ -147,6 +147,9 @@ dbg "ARGS = $ARGS" [[ ! -d "$WD" ]] && stderr "No directory: $WD" && exit 1 +TAG_TARGET=$(__git "$WD" rev-parse HEAD) +stdout "Tag in config will be generated at '$TAG_TARGET'" + if [[ -z "$DONT_BUILD" ]] then __q="-Q" @@ -181,7 +184,7 @@ then fi fi -__git "$WD" tag $TAG_FLAGS "$TAG_NAME" +__git "$WD" tag $TAG_FLAGS "$TAG_NAME" "$TAG_TARGET" if [[ $TAG_NIXPKGS -eq 1 ]] then -- cgit v1.2.3