Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, writeScript
3}:
4
5{ name ? ""
6, owner ? ""
7, repo ? ""
8, page ? "releases?per_page=1"
9, filter ? ".[0].tag_name | split(\"-\") | .[1]"
10}:
11
12let
13 pname =
14 if lib.hasPrefix "rocm-llvm-" name
15 then "llvmPackages_rocm.${lib.removePrefix "rocm-llvm-" name}"
16 else name;
17
18 updateScript = writeScript "update.sh" ''
19 #!/usr/bin/env nix-shell
20 #!nix-shell -i bash -p curl jq common-updater-scripts
21 version="$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
22 -sL "https://api.github.com/repos/${owner}/${repo}/${page}" | jq '${filter}' --raw-output)"
23
24 IFS='.' read -a version_arr <<< "$version"
25
26 if [ "''${#version_arr[*]}" == 2 ]; then
27 version="''${version}.0"
28 fi
29
30 update-source-version ${pname} "$version" --ignore-same-hash
31 '';
32in [ updateScript ]