nixpkgs-update: add fetch-repology script
This commit is contained in:
parent
f1a8beb4ab
commit
c029c3d453
2 changed files with 73 additions and 3 deletions
hosts/build02
|
@ -109,6 +109,14 @@ let
|
|||
startAt = "0/12:10"; # every 12 hours
|
||||
};
|
||||
|
||||
repology = pkgs.writeShellApplication {
|
||||
name = "repology";
|
||||
runtimeInputs = [
|
||||
pkgs.jq
|
||||
pkgs.moreutils
|
||||
];
|
||||
text = builtins.readFile ./repology.bash;
|
||||
};
|
||||
in
|
||||
{
|
||||
users.groups.r-ryantm = { };
|
||||
|
@ -147,10 +155,9 @@ in
|
|||
script = "${nixpkgs-update-bin} delete-done --delete";
|
||||
};
|
||||
|
||||
systemd.services.nixpkgs-update-fetch-repology = mkFetcher "repology" "${nixpkgs-update-bin} fetch-repology";
|
||||
|
||||
systemd.services.nixpkgs-update-fetch-updatescript = mkFetcher "updatescript" "${pkgs.nix}/bin/nix eval --option max-call-depth 100000 --raw -f ${./packages-with-update-script.nix}";
|
||||
systemd.services.nixpkgs-update-fetch-github = mkFetcher "github" "${inputs.nixpkgs-update-github-releases}/main.py";
|
||||
systemd.services.nixpkgs-update-fetch-repology = mkFetcher "repology" (lib.getExe repology);
|
||||
systemd.services.nixpkgs-update-fetch-updatescript = mkFetcher "updatescript" "${pkgs.nix}/bin/nix eval --option max-call-depth 100000 --raw -f ${./packages-with-update-script.nix}";
|
||||
|
||||
systemd.services.nixpkgs-update-worker1 = mkWorker "worker1";
|
||||
systemd.services.nixpkgs-update-worker2 = mkWorker "worker2";
|
||||
|
|
63
hosts/build02/repology.bash
Executable file
63
hosts/build02/repology.bash
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
file=$(mktemp)
|
||||
>&2 echo "$file"
|
||||
|
||||
fetch() {
|
||||
local url="$1"
|
||||
>&2 echo "$url"
|
||||
curl --silent --compressed --user-agent "https://github.com/nix-community/infra" --location "$url"
|
||||
}
|
||||
|
||||
fetch "https://repology.org/api/v1/projects/?inrepo=nix_unstable&outdated=1" >"$file"
|
||||
|
||||
append() {
|
||||
sleep 2
|
||||
local last="$1"
|
||||
local url="https://repology.org/api/v1/projects/$last/?inrepo=nix_unstable&outdated=1"
|
||||
fetch "$url" >>"$file"
|
||||
}
|
||||
|
||||
while true; do
|
||||
last=$(jq --sort-keys --raw-output 'keys | last' <"$file")
|
||||
|
||||
append "$last"
|
||||
|
||||
jq --slurp add "$file" | sponge "$file"
|
||||
|
||||
final=$(jq --sort-keys --raw-output 'keys | last' <"$file")
|
||||
if [[ $last == "$final" ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
jq -r '
|
||||
to_entries |
|
||||
map(select(.value | type == "array")) |
|
||||
map({
|
||||
name: (
|
||||
.value |
|
||||
map(select(.repo == "nix_unstable")) |
|
||||
.[0] |
|
||||
.srcname
|
||||
),
|
||||
oldVersion: (
|
||||
.value |
|
||||
map(select(.repo == "nix_unstable" and .status == "outdated")) |
|
||||
.[0] |
|
||||
.version
|
||||
),
|
||||
newVersion: (
|
||||
.value |
|
||||
map(select(.status == "newest" and .version != null)) |
|
||||
.[0] |
|
||||
.version
|
||||
),
|
||||
url: "https://repology.org/project/\(.key)/versions"
|
||||
}) |
|
||||
map(select(.newVersion != null)) |
|
||||
map("\(.name) \(.oldVersion) \(.newVersion) \(.url)") |
|
||||
join("\n")
|
||||
' <"$file" | sort
|
Loading…
Add table
Reference in a new issue