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:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
/result
|
/result
|
||||||
/*-linux.tar.gz
|
/*-linux.tar.gz
|
||||||
|
/update-targets.mk
|
||||||
|
|||||||
18
Makefile
18
Makefile
@@ -1,12 +1,18 @@
|
|||||||
BIN_DIR := ${HOME}/.local/bin
|
BIN_DIR := ${HOME}/.local/bin
|
||||||
SCRIPTS := $(BIN_DIR)/rebuild-nixos
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: install link update-targets
|
||||||
all: $(SCRIPTS)
|
|
||||||
|
install: $(BIN_DIR)
|
||||||
|
cp script/rebuild-nixos $(BIN_DIR)/
|
||||||
|
chmod +x $(BIN_DIR)/rebuild-nixos
|
||||||
|
|
||||||
|
link: $(BIN_DIR)
|
||||||
|
ln -sf $(CURDIR)/script/rebuild-nixos $(BIN_DIR)/
|
||||||
|
|
||||||
$(BIN_DIR):
|
$(BIN_DIR):
|
||||||
mkdir -p $(BIN_DIR)
|
mkdir -p $(BIN_DIR)
|
||||||
|
|
||||||
$(BIN_DIR)/rebuild-nixos: script/rebuild-nixos
|
update-targets.mk: flake.nix script/gen-update-targets.sh
|
||||||
cp script/rebuild-nixos $(BIN_DIR)/
|
script/gen-update-targets.sh > $@
|
||||||
chmod +x $(BIN_DIR)/rebuild-nixos
|
|
||||||
|
-include update-targets.mk
|
||||||
|
|||||||
46
flake.lock
generated
46
flake.lock
generated
@@ -164,17 +164,17 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1774588158,
|
"lastModified": 1774593162,
|
||||||
"narHash": "sha256-CM0CyFJ/XtxZWDKtBSgf6thY4/NZR72y8Muy4SD9oAk=",
|
"narHash": "sha256-jYcIAwdULM2O06rNerW3PGp+cOQKlvk2DjmgnmDxzP8=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "dc1816b159cc5095b8ddd7c3f942626243c0878b",
|
"rev": "a45ed03432096f04b0fb6fd410e76a61223f4228",
|
||||||
"revCount": 27,
|
"revCount": 28,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mc-proxy"
|
"url": "https://git@git.wntrmute.dev/mc/mc-proxy"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mc-proxy"
|
"url": "https://git@git.wntrmute.dev/mc/mc-proxy"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mcdeploy": {
|
"mcdeploy": {
|
||||||
@@ -190,11 +190,11 @@
|
|||||||
"rev": "9c016e54ecbc3546b189af935f27ca0ad461c14f",
|
"rev": "9c016e54ecbc3546b189af935f27ca0ad461c14f",
|
||||||
"revCount": 4,
|
"revCount": 4,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mcdeploy"
|
"url": "https://git@git.wntrmute.dev/mc/mcdeploy"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mcdeploy"
|
"url": "https://git@git.wntrmute.dev/mc/mcdeploy"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mcias": {
|
"mcias": {
|
||||||
@@ -208,11 +208,11 @@
|
|||||||
"rev": "9b521f3d999e8950c2268c2240c490f8509db60f",
|
"rev": "9b521f3d999e8950c2268c2240c490f8509db60f",
|
||||||
"revCount": 95,
|
"revCount": 95,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mcias.git"
|
"url": "https://git@git.wntrmute.dev/mc/mcias.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mcias.git"
|
"url": "https://git@git.wntrmute.dev/mc/mcias.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mcp": {
|
"mcp": {
|
||||||
@@ -222,11 +222,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1774590396,
|
"lastModified": 1774595952,
|
||||||
"narHash": "sha256-FyQNU//OHqjsU7wqJt5iosxwjbQafpmTORNyq7k+t+I=",
|
"narHash": "sha256-AlivqmqpRuCav0Eu7sEpGDg0pxMeC7rNVewxelHSKZI=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "e18a3647bfbc1a8a452133f8617bec6105776485",
|
"rev": "503c52dc269ca834b8b38d1a242ed48971ee17cb",
|
||||||
"revCount": 22,
|
"revCount": 24,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/mc/mcp"
|
"url": "https://git@git.wntrmute.dev/mc/mcp"
|
||||||
},
|
},
|
||||||
@@ -242,17 +242,17 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1774588281,
|
"lastModified": 1774593062,
|
||||||
"narHash": "sha256-OAncdSzGgH7zcRaBwBSQMc8ofVMNrNlsnMwMounARa4=",
|
"narHash": "sha256-Mwt4+JkGUyFiwjnLMJGrAA/n9950c3X/waV3DiUB3d4=",
|
||||||
"ref": "refs/heads/master",
|
"ref": "refs/heads/master",
|
||||||
"rev": "3d36c58d0d672745f34301515ca568466bfb37a6",
|
"rev": "acc4851549a01642952314e03e4d8d91002f8824",
|
||||||
"revCount": 24,
|
"revCount": 26,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mcr"
|
"url": "https://git@git.wntrmute.dev/mc/mcr"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git@git.wntrmute.dev/kyle/mcr"
|
"url": "https://git@git.wntrmute.dev/mc/mcr"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nix-index-database": {
|
"nix-index-database": {
|
||||||
@@ -365,11 +365,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1774551446,
|
"lastModified": 1774596342,
|
||||||
"narHash": "sha256-dnX6zMTp4jqbcjlD5qenBYftE/OvHpqKugGLLKj1/bg=",
|
"narHash": "sha256-FlUcJydnZmj0l7a08z+viSQEwtvnNFggJqlECMHfUBY=",
|
||||||
"owner": "kisom",
|
"owner": "kisom",
|
||||||
"repo": "sgard",
|
"repo": "sgard",
|
||||||
"rev": "b9b9082008424b7610ef6d7cf2bbcb47d1ea697d",
|
"rev": "de5759ac77a2aadc43d48e52e3f53551b3353659",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -32,15 +32,15 @@
|
|||||||
cert.url = "github:kisom/cert";
|
cert.url = "github:kisom/cert";
|
||||||
cert.inputs.nixpkgs.follows = "nixpkgs";
|
cert.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
mcias.url = "git+https://git@git.wntrmute.dev/kyle/mcias.git";
|
mcias.url = "git+https://git@git.wntrmute.dev/mc/mcias.git";
|
||||||
|
|
||||||
mcr.url = "git+https://git@git.wntrmute.dev/kyle/mcr";
|
mcr.url = "git+https://git@git.wntrmute.dev/mc/mcr";
|
||||||
mcr.inputs.nixpkgs.follows = "nixpkgs";
|
mcr.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
mc-proxy.url = "git+https://git@git.wntrmute.dev/kyle/mc-proxy";
|
mc-proxy.url = "git+https://git@git.wntrmute.dev/mc/mc-proxy";
|
||||||
mc-proxy.inputs.nixpkgs.follows = "nixpkgs";
|
mc-proxy.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
mcdeploy.url = "git+https://git@git.wntrmute.dev/kyle/mcdeploy";
|
mcdeploy.url = "git+https://git@git.wntrmute.dev/mc/mcdeploy";
|
||||||
mcdeploy.inputs.nixpkgs.follows = "nixpkgs";
|
mcdeploy.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
mcp.url = "git+https://git@git.wntrmute.dev/mc/mcp";
|
mcp.url = "git+https://git@git.wntrmute.dev/mc/mcp";
|
||||||
|
|||||||
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