Rework Makefile with install/link/update targets and auto-generation
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>
This commit is contained in:
35
script/gen-update-targets.sh
Executable file
35
script/gen-update-targets.sh
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user