#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/.." declare -A groups while IFS= read -r line; do # skip comments [[ $line =~ ^[[:space:]]*# ]] && continue if [[ $line =~ ^[[:space:]]*([a-zA-Z0-9_-]+)\.url[[:space:]]*=[[:space:]]*\"(.+)\"\; ]]; then name="${BASH_REMATCH[1]}" url="${BASH_REMATCH[2]}" if [[ $url =~ wntrmute\.dev/kyle/ ]] || [[ $url =~ github:kisom/ ]]; then groups[kyle]+="${groups[kyle]:+ }$name" elif [[ $url =~ wntrmute\.dev/mc/ ]]; then groups[mc]+="${groups[mc]:+ }$name" fi fi done < flake.nix phony="" targets="" for group in $(printf '%s\n' "${!groups[@]}" | sort); do inputs="${groups[$group]}" if [[ -n "$inputs" ]]; then phony+=" update-$group" targets+="update-${group}:"$'\n\t'"nix flake update ${inputs}"$'\n\n' fi done printf '.PHONY:%s\n\n%s' "$phony" "$targets"