commit 7e0d1c8213ab16739e6a6530fdfd467202fba22e
parent e4008eb94b7c0759be71f469987ee76aa9846d13
Author: Vincent Demeester <vincent@sbr.pm>
Date: Fri, 5 Jun 2020 18:22:26 +0200
./hack/system: fix WORK_DIR handling…
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/hack/system b/hack/system
@@ -1,7 +1,13 @@
#! /usr/bin/env bash
set -o pipefail -o noclobber -o nounset
-
-WORKDIR=${WORKDIR-}
+set -x
+
+WORK_DIR=${WORK_DIR-}
+if [[ -z "${WORK_DIR}" ]]; then
+ WORK_DIR="$(mktemp --tmpdir -u nix-config-sync.XXXXXXXXXX)"
+ # shellcheck disable=2064
+ trap "rm -rf '$WORK_DIR'" EXIT
+fi
function error() {
local red
local reset
@@ -12,19 +18,8 @@ function error() {
exit 1
}
-function set_work_dir() {
- if [[ -z "${WORKDIR}" && ! -v WORK_DIR ]]; then
- WORK_DIR="$(mktemp --tmpdir -u nix-config-sync.XXXXXXXXXX)"
- # shellcheck disable=2064
- trap "rm -rf '$WORK_DIR'" EXIT
- else
- WORK_DIR="${WORKDIR}"
- fi
-}
-
function dry-build() {
[ "$#" -eq 0 ] || error "build"
- set_work_dir
local machine
machine="$(hostname)"
unset NIX_PATH
@@ -34,7 +29,6 @@ function dry-build() {
function build() {
[ "$#" -eq 0 ] || error "build"
- set_work_dir
local machine
machine="$(hostname)"
unset NIX_PATH
@@ -45,7 +39,6 @@ function build() {
function switch() {
[ "$#" -eq 0 ] || error "switch"
build
- set_work_dir
local switch_bin="$WORK_DIR/bin/switch-to-configuration"
sudo nix-env --set \
--profile "/nix/var/nix/profiles/system" \