Skip to content

Commit

Permalink
lib: update
Browse files Browse the repository at this point in the history
  • Loading branch information
pnmadelaine committed Sep 30, 2023
1 parent aff4227 commit b614593
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 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'
'';
});
}
33 changes: 20 additions & 13 deletions nix/lib/mkGitJobsets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'
'';
});
}

0 comments on commit b614593

Please sign in to comment.