#!/usr/bin/env bash set -euo pipefail repo_root="$(git rev-parse --show-toplevel)" flake_ref="path:${repo_root}" # Use a path flake ref so ignored files, especially the local flake.lock, are # visible to Nix even though the repository itself is a Git worktree. targets_text="$( nix eval \ --raw \ --no-write-lock-file \ "${flake_ref}#nixosConfigurations" \ --apply 'configs: builtins.concatStringsSep "\n" (builtins.attrNames configs)' )" targets=() while IFS= read -r target; do if [ -n "${target}" ]; then targets+=("${target}") fi done <<< "${targets_text}" if [ "${#targets[@]}" -eq 0 ]; then echo "No nixosConfigurations found to evaluate." >&2 exit 1 fi for target in "${targets[@]}"; do echo "Evaluating nixosConfigurations.${target}.config.system.build.toplevel" nix eval \ --raw \ --no-write-lock-file \ "${flake_ref}#nixosConfigurations.${target}.config.system.build.toplevel.drvPath" \ >/dev/null done