#!/usr/bin/env bash set -euo pipefail top=$(dirname "$(realpath "$0")") configPath="$top/hosts/$HOSTNAME/default.nix" if [ ! -f $configPath ]; then echo "aborting: $configPath 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 ' ) # FIXME: change into host directory for host-specific garbage collector roots cd "$top" # 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="$top"