#!/usr/bin/env bash set -euo pipefail # Enable all future paths in this script to be relative to the directory containing the script. cd "$(dirname -- "${BASH_SOURCE[0]}")" configPath=$(realpath -- "hosts/$HOSTNAME/default.nix") if [ ! -f $configPath ]; then echo "aborting: $configPath doesn't exist" exit 1 fi nixpkgsPath=$( 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 ' ) # nixos-rebuild always reads Nixpkgs from the NIX_PATH, # so we need to set it explicitly to our pinned version exec nixos-rebuild "$@" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$(pwd)"