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/github/mkGithubProject.nix b/nix/lib/github/mkGithubProject.nix index d6fd55cb..943eec87 100644 --- a/nix/lib/github/mkGithubProject.nix +++ b/nix/lib/github/mkGithubProject.nix @@ -17,11 +17,12 @@ in { title ? repo, description ? "", homepage ? "https://github.com/${owner}/${repo}", + legacy ? false, }: mkProject { meta = {inherit title description homepage;}; actions = { - jobsets = mkGithubJobsets {inherit owner repo;}; + jobsets = mkGithubJobsets {inherit owner repo legacy;}; begin = mkGithubStatus {inherit owner repo;}; end = mkGithubStatus {inherit owner repo;}; webhook = githubWebhook; diff --git a/nix/lib/github/mkGithubStatus.nix b/nix/lib/github/mkGithubStatus.nix index 4101f2d5..4d9a977b 100644 --- a/nix/lib/github/mkGithubStatus.nix +++ b/nix/lib/github/mkGithubStatus.nix @@ -23,7 +23,7 @@ in { build=$(echo "$input" | jq '.input.build' -r) data=$(echo "$input" | jq '.input.data' -r) - flake_locked=$(echo "$input" | jq '.input.flake_locked' -r) + url_locked=$(echo "$input" | jq '.input.url_locked' -r) job=$(echo "$input" | jq '.input.job' -r) status=$(echo "$input" | jq '.input.status' -r) system=$(echo "$input" | jq '.input.system' -r) diff --git a/nix/lib/mkGitJobsets.nix b/nix/lib/mkGitJobsets.nix index 9fd81ff6..e22fb1c9 100644 --- a/nix/lib/mkGitJobsets.nix +++ b/nix/lib/mkGitJobsets.nix @@ -4,7 +4,10 @@ utils: lib: let eachSystem ; in { - mkGitJobsets = url: + mkGitJobsets = { + url, + legacy ? false, + }: eachSystem (system: let pkgs = utils.pkgs.${system}; in @@ -17,13 +20,13 @@ in { ]; 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' ''; }); }