33 lines
1 KiB
Bash
Executable file
33 lines
1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# FLAKE_PATH="${1:-/tmp/flake}"
|
|
FLAKE_PATH=./flake.nix
|
|
CACHE="mycache"
|
|
GC_ROOT="/tmp/gcroots-ci"
|
|
mkdir -p "$GC_ROOT"
|
|
|
|
declare -a paths_to_push
|
|
|
|
# Build all NixOS configs
|
|
nixos_configs=$(nix eval --json "$FLAKE_PATH#nixosConfigurations" --apply 'builtins.attrNames' | jq -r '.[]')
|
|
for host in $nixos_configs; do
|
|
echo "▶ Building NixOS config: $host"
|
|
out_path=$(nix build --print-out-paths "$FLAKE_PATH#nixosConfigurations.${host}.config.system.build.toplevel")
|
|
paths_to_push+=("$out_path")
|
|
done
|
|
|
|
# Build all Home Manager configs
|
|
home_configs=$(nix eval --json "$FLAKE_PATH#homeConfigurations" --apply 'builtins.attrNames' | jq -r '.[]')
|
|
for user in $home_configs; do
|
|
echo "▶ Building Home config: $user"
|
|
out_path=$(nix build --print-out-paths "$FLAKE_PATH#homeConfigurations.${user}.activationPackage")
|
|
paths_to_push+=("$out_path")
|
|
done
|
|
|
|
# Push all at once
|
|
echo "📦 Pushing ${#paths_to_push[@]} paths to attic cache: $CACHE"
|
|
attic push "$CACHE" "${paths_to_push[@]}"
|
|
|
|
# Clean up
|
|
nix store delete "${paths_to_push[@]}"
|