From 940fb56e7e450b7da56cc333d17ab0edb4cd1d0f Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 26 Apr 2025 08:26:08 +0200 Subject: refactor: move channel metadata to separate .toml files --- nixos/rebuild | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'nixos/rebuild') 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, -- cgit v1.2.3