aboutsummaryrefslogtreecommitdiff
path: root/nixos/rebuild
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-10-17 10:36:36 +0200
committerMartin Fischer <martin@push-f.com>2026-10-17 17:02:46 +0200
commitf29ddff912ddcd58a4726736702b24655505ce09 (patch)
treed43e33c1320f229dc448bae2ccdc813a78d5f2de /nixos/rebuild
parentc8165d2a72b9e2e2c67c4b1aad40a0c3e256dd4d (diff)
refactor: introduce nixos/default.nix
The system prompt addition is to make it run `npins show <pin>` rather than `npins show` when looking for a specific pin. `npins get-path` is mentioned because the model doesn't "know" it yet (the subcommand was introduced in 2025 Dec).
Diffstat (limited to 'nixos/rebuild')
-rwxr-xr-xnixos/rebuild38
1 files changed, 3 insertions, 35 deletions
diff --git a/nixos/rebuild b/nixos/rebuild
index 3c675b2..395f78d 100755
--- a/nixos/rebuild
+++ b/nixos/rebuild
@@ -3,49 +3,17 @@ set -euo pipefail
top=$(dirname "$(realpath "$0")")
hostDir="$top/hosts/$HOSTNAME"
-defaultConfigPath="$hostDir/default.nix"
-privateConfigPath="$hostDir/private.nix"
-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"
+if [ ! -d "$hostDir" ]; then
+ echo "aborting: host directory $hostDir doesn't exist"
exit 1
fi
-nixpkgsPath=$(
- cd "$top" &&
- nix-instantiate --eval --raw \
- --argstr host "$HOSTNAME" \
- --expr '
- { host }:
- let
- toml = builtins.readFile ./hosts/${host}/metadata.toml;
- channel = (builtins.fromTOML toml).channel;
- in
- (import ./npins).${channel}.outPath
- '
-)
-
(
# 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 "$hostDir" &&
- # nixos-rebuild always reads Nixpkgs from the NIX_PATH,
- # so we need to set it explicitly to our pinned version
- exec nixos-rebuild "$@" --file "$top/system.nix" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath"
+ exec nixos-rebuild "$@" --file "$top/default.nix" --attr "configurations.$HOSTNAME"
)