diff options
-rw-r--r-- | nixos/README.md | 3 | ||||
-rw-r--r-- | nixos/hosts/ev/default.nix | 1 | ||||
-rw-r--r-- | nixos/hosts/ev/metadata.toml | 1 | ||||
-rw-r--r-- | nixos/hosts/hamac/default.nix | 1 | ||||
-rw-r--r-- | nixos/hosts/hamac/metadata.toml | 1 | ||||
-rw-r--r-- | nixos/hosts/tente/default.nix | 1 | ||||
-rw-r--r-- | nixos/hosts/tente/metadata.toml | 1 | ||||
-rwxr-xr-x | nixos/rebuild | 15 |
8 files changed, 12 insertions, 12 deletions
diff --git a/nixos/README.md b/nixos/README.md index 67b6cf7..075f812 100644 --- a/nixos/README.md +++ b/nixos/README.md @@ -32,7 +32,8 @@ We're assuming that you just installed NixOS by going through the [official inst nixos-generate-config --dir . ``` 3. Rename the `configuration.nix` to `default.nix`. - Add `# channel="..."` to the start of the `default.nix` file where `...` is the key of a channel pinned in `npins/sources.json`. + Create a `metadata.toml` file with a `channel` field + where the value is the key of a channel pinned in `npins/sources.json`. A new channel can be pinned with: ``` diff --git a/nixos/hosts/ev/default.nix b/nixos/hosts/ev/default.nix index e59ec01..9842f4f 100644 --- a/nixos/hosts/ev/default.nix +++ b/nixos/hosts/ev/default.nix @@ -1,4 +1,3 @@ -# channel="nixos-small" # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). diff --git a/nixos/hosts/ev/metadata.toml b/nixos/hosts/ev/metadata.toml new file mode 100644 index 0000000..58f0301 --- /dev/null +++ b/nixos/hosts/ev/metadata.toml @@ -0,0 +1 @@ +channel = "nixos-small" diff --git a/nixos/hosts/hamac/default.nix b/nixos/hosts/hamac/default.nix index 7085ed3..08caa51 100644 --- a/nixos/hosts/hamac/default.nix +++ b/nixos/hosts/hamac/default.nix @@ -1,4 +1,3 @@ -# channel="nixos" # See the configuration.nix(5) man page and the NixOS manual (accessible by running `nixos-help`). let diff --git a/nixos/hosts/hamac/metadata.toml b/nixos/hosts/hamac/metadata.toml new file mode 100644 index 0000000..fc34e27 --- /dev/null +++ b/nixos/hosts/hamac/metadata.toml @@ -0,0 +1 @@ +channel = "nixos" diff --git a/nixos/hosts/tente/default.nix b/nixos/hosts/tente/default.nix index 7ecb793..638b8d9 100644 --- a/nixos/hosts/tente/default.nix +++ b/nixos/hosts/tente/default.nix @@ -1,4 +1,3 @@ -# channel="nixos-small" # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page, on # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). diff --git a/nixos/hosts/tente/metadata.toml b/nixos/hosts/tente/metadata.toml new file mode 100644 index 0000000..58f0301 --- /dev/null +++ b/nixos/hosts/tente/metadata.toml @@ -0,0 +1 @@ +channel = "nixos-small" 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, |