diff --git a/nix/lib/github/mkGithubJobsets.nix b/nix/lib/github/mkGithubJobsets.nix index 2887e980..5b0e9550 100644 --- a/nix/lib/github/mkGithubJobsets.nix +++ b/nix/lib/github/mkGithubJobsets.nix @@ -7,6 +7,7 @@ in { mkGithubJobsets = { owner, repo, + legacy ? false, }: eachSystem (system: let pkgs = utils.pkgs.${system}; @@ -26,8 +27,12 @@ in { -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $token" \ https://api.github.com/repos/${owner}/${repo}/branches \ - -k \ - | jq --arg o "${owner}" --arg r "${repo}" 'map({ key: .name, value: { "flake": ("github:" + $o + "/" + $r + "/" + .name) }}) | from_entries' + -k \ | jq '. + | map({ (.name): { + "url": ("github:${owner}/${repo}/" + .name), + "legacy": ${utils.lib.boolToString legacy} + }}) + | add' ''; }); } diff --git a/nix/lib/mkGitJobsets.nix b/nix/lib/mkGitJobsets.nix index 9fd81ff6..e026be2b 100644 --- a/nix/lib/mkGitJobsets.nix +++ b/nix/lib/mkGitJobsets.nix @@ -4,26 +4,33 @@ utils: lib: let eachSystem ; in { - mkGitJobsets = url: + mkGitJobsets = { + url, + legacy ? false, + }: eachSystem (system: let pkgs = utils.pkgs.${system}; in pkgs.writeShellApplication { name = "action"; - runtimeInputs = [ - pkgs.git - pkgs.gnused - pkgs.jq - ]; + runtimeInputs = builtins.attrValues { + inherit + (pkgs) + git + gnused + jq + nix + ; + }; text = '' heads=$(git ls-remote --heads ${url} | sed 's/.*refs\/heads\/\(.*\)/\1/') - cmd="" - for head in $heads - do - cmd="$cmd . += {\"$head\": { \"flake\": \"git+${url}?ref=$head\" } } |" - done - array=$(echo "{}" | jq "$cmd .") - echo "$array" + echo null | jq --arg heads "$heads" '$heads + | split("\n") + | map({(.): { + "url": ("git+${url}?ref=" + .), + "legacy": ${utils.lib.boolToString legacy} + }}) + | add' ''; }); }