Skip to content

Commit

Permalink
lib: update
Browse files Browse the repository at this point in the history
  • Loading branch information
pnmadelaine committed Oct 1, 2023
1 parent ad85b25 commit 127a369
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
9 changes: 7 additions & 2 deletions nix/lib/github/mkGithubJobsets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ in {
mkGithubJobsets = {
owner,
repo,
legacy ? false,
}:
eachSystem (system: let
pkgs = utils.pkgs.${system};
Expand All @@ -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'
'';
});
}
3 changes: 2 additions & 1 deletion nix/lib/github/mkGithubProject.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion nix/lib/github/mkGithubStatus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 11 additions & 8 deletions nix/lib/mkGitJobsets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ utils: lib: let
eachSystem
;
in {
mkGitJobsets = url:
mkGitJobsets = {
url,
legacy ? false,
}:
eachSystem (system: let
pkgs = utils.pkgs.${system};
in
Expand All @@ -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'
'';
});
}

0 comments on commit 127a369

Please sign in to comment.