summaryrefslogtreecommitdiff
path: root/nixos/rebuild
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-04-26 08:26:08 +0200
committerMartin Fischer <martin@push-f.com>2025-04-26 08:39:32 +0200
commit940fb56e7e450b7da56cc333d17ab0edb4cd1d0f (patch)
tree4ffd3e20cbd4de5b8d25827e294f7b7b3ba22dd4 /nixos/rebuild
parentc329be48e687e3152e1362a71b76035bfda7215e (diff)
refactor: move channel metadata to separate .toml filesHEADmaster
Diffstat (limited to 'nixos/rebuild')
-rwxr-xr-xnixos/rebuild15
1 files changed, 7 insertions, 8 deletions
diff --git a/nixos/rebuild b/nixos/rebuild
index 80a52cd..cfc14cf 100755
--- a/nixos/rebuild
+++ b/nixos/rebuild
@@ -11,19 +11,18 @@ if [ ! -f $configPath ]; then
exit 1
fi
-firstLine=$(head -n1 "$configPath")
-
-if ! echo "$firstLine" | grep -E ^"# channel *=" > /dev/null; then
- echo "aborting: $configPath doesn't start with \`# channel=\"...\"\`, where ... is a pin from sources.json"
- exit 1
-fi
-
nix-eval() {
+ # FUTURE: use --raw when upgrading to NixOS 25.05
nix-instantiate --eval --read-write-mode "$@" \
| tr -d \" # nix-instantiate has no raw output yet (like the experimental nix eval)
}
-channel=$(nix-eval --argstr line "$(echo $firstLine | tr -d \#)" --expr '{line}: (builtins.fromTOML line).channel')
+channel=$(nix-eval --argstr host "$HOSTNAME" --expr '{host}:
+let
+ toml = builtins.readFile ./hosts/${host}/metadata.toml;
+in
+ (builtins.fromTOML toml).channel
+')
nixpkgsPath=$(nix-eval --argstr channel "$channel" --expr '{channel}: (import ./npins).${channel}.outPath')
# nixos-rebuild always reads Nixpkgs from the NIX_PATH,