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 0e896e8 commit 9d64415
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 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'
'';
});
}
13 changes: 6 additions & 7 deletions nix/utils.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{sources ? import ./sources.nix}: let
inherit
(sources)
nixpkgs
;
{
sources ? import ./sources.nix,
systems ? import ./systems.nix,
}: let
self = rec {
lib = sources.nixpkgs.lib;

pkgs = sources.nixpkgs.legacyPackages;
pkgs = lib.genAttrs systems (system: import ./nixpkgs.nix {inherit sources system;});

unionOfDisjoint = x: y:
if builtins.intersectAttrs x y == {}
Expand All @@ -20,7 +19,7 @@

importer = scope: files:
mkScope scope (
nixpkgs.lib.foldr
lib.foldr
(file: fn: lib:
unionOfDisjoint
(import file self lib)
Expand Down

0 comments on commit 9d64415

Please sign in to comment.