aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xnixos/rebuild11
1 files changed, 6 insertions, 5 deletions
diff --git a/nixos/rebuild b/nixos/rebuild
index 7fa750a..d902bd8 100755
--- a/nixos/rebuild
+++ b/nixos/rebuild
@@ -1,10 +1,8 @@
#!/usr/bin/env bash
set -euo pipefail
-# Enable all future paths in this script to be relative to the directory containing the script.
-cd "$(dirname -- "${BASH_SOURCE[0]}")"
-
-configPath=$(realpath -- "hosts/$HOSTNAME/default.nix")
+top=$(dirname "$(realpath "$0")")
+configPath="$top/hosts/$HOSTNAME/default.nix"
if [ ! -f $configPath ]; then
echo "aborting: $configPath doesn't exist"
@@ -12,6 +10,7 @@ if [ ! -f $configPath ]; then
fi
nixpkgsPath=$(
+ cd "$top" &&
nix-instantiate --eval --raw \
--argstr host "$HOSTNAME" \
--expr '
@@ -24,6 +23,8 @@ nixpkgsPath=$(
'
)
+# FIXME: change into host directory for host-specific garbage collector roots
+cd "$top"
# nixos-rebuild always reads Nixpkgs from the NIX_PATH,
# so we need to set it explicitly to our pinned version
-exec nixos-rebuild "$@" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$(pwd)"
+exec nixos-rebuild "$@" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$top"