Add gen-update-targets.sh to parse flake.nix and generate grouped update targets (update-kyle, update-mc). Makefile now has install (copy) and link (symlink) targets for rebuild-nixos. Also fix mc flake input URLs to use /mc/ org path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
841 B
Bash
Executable File
36 lines
841 B
Bash
Executable File
#!/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"
|