aboutsummaryrefslogtreecommitdiff
path: root/nixos/rebuild
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-09-30 10:59:24 +0200
committerMartin Fischer <martin@push-f.com>2026-09-30 11:00:58 +0200
commit748d3282d351107723e79060a9471b08e66c4670 (patch)
treee1d52d7ae8a4095683a70e1dd2079de17ddc5c60 /nixos/rebuild
parentd1f67c929ae7397b7ae241bb59932113b5f9e4c1 (diff)
refactor: move absolute path imports to private.nix
Diffstat (limited to 'nixos/rebuild')
-rwxr-xr-xnixos/rebuild22
1 files changed, 19 insertions, 3 deletions
diff --git a/nixos/rebuild b/nixos/rebuild
index 9e62b33..d6a06a8 100755
--- a/nixos/rebuild
+++ b/nixos/rebuild
@@ -2,9 +2,25 @@
set -euo pipefail
top=$(dirname "$(realpath "$0")")
-configPath="$top/hosts/$HOSTNAME/default.nix"
+hostDir="$top/hosts/$HOSTNAME"
+defaultConfigPath="$hostDir/default.nix"
+privateConfigPath="$hostDir/private.nix"
-if [ ! -f $configPath ]; then
+case "${1:-}" in
+ --default)
+ configPath="$defaultConfigPath"
+ shift
+ ;;
+ *)
+ if [ -f "$privateConfigPath" ]; then
+ configPath="$privateConfigPath"
+ else
+ configPath="$defaultConfigPath"
+ fi
+ ;;
+esac
+
+if [ ! -f "$configPath" ]; then
echo "aborting: $configPath doesn't exist"
exit 1
fi
@@ -27,7 +43,7 @@ nixpkgsPath=$(
# The result symlink created in the current directory is registered as a root of the Nix
# garbage collector, so it's important that we call nixos-rebuild from the host directory.
# (nix-build has an --out-link option but that option cannot be set via nixos-rebuild).
- cd $top/hosts/$HOSTNAME &&
+ cd "$hostDir" &&
# nixos-rebuild always reads Nixpkgs from the NIX_PATH,
# so we need to set it explicitly to our pinned version