2024-04-20 13:23:49 -04:00
|
|
|
{
|
|
|
|
nixpkgs,
|
|
|
|
pulls,
|
|
|
|
feature-branches,
|
|
|
|
flake-update-branches,
|
|
|
|
...
|
|
|
|
}:
|
2024-04-03 02:34:17 -04:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { };
|
|
|
|
|
2024-04-20 13:23:49 -04:00
|
|
|
makeSpec =
|
|
|
|
contents:
|
|
|
|
builtins.derivation {
|
|
|
|
name = "spec.json";
|
|
|
|
system = "x86_64-linux";
|
|
|
|
preferLocalBuild = true;
|
|
|
|
allowSubstitutes = false;
|
|
|
|
builder = "/bin/sh";
|
|
|
|
args = [
|
|
|
|
(builtins.toFile "builder.sh" ''
|
|
|
|
echo "$contents" > $out
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
contents = builtins.toJSON contents;
|
|
|
|
};
|
2024-04-03 02:34:17 -04:00
|
|
|
|
2024-04-20 13:23:49 -04:00
|
|
|
prs = builtins.fromJSON (builtins.readFile pulls);
|
|
|
|
branches = builtins.fromJSON (builtins.readFile feature-branches);
|
|
|
|
update = builtins.fromJSON (builtins.readFile flake-update-branches);
|
|
|
|
repo = "ahuston-0/nix-dotfiles-hydra";
|
2024-04-03 02:34:17 -04:00
|
|
|
|
2024-04-20 13:23:49 -04:00
|
|
|
makeJob =
|
|
|
|
{
|
|
|
|
schedulingshares ? 10,
|
|
|
|
keepnr ? 3,
|
|
|
|
description,
|
|
|
|
flake,
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
inherit
|
|
|
|
description
|
|
|
|
flake
|
|
|
|
schedulingshares
|
|
|
|
keepnr
|
|
|
|
;
|
|
|
|
enabled = 1;
|
|
|
|
type = 1;
|
|
|
|
hidden = false;
|
|
|
|
checkinterval = 300; # every 6 months
|
|
|
|
enableemail = false;
|
|
|
|
emailoverride = "";
|
|
|
|
};
|
|
|
|
jobOfRef =
|
|
|
|
name:
|
|
|
|
{ ref, ... }:
|
|
|
|
if isNull (builtins.match "^refs/heads/(.*)$" ref) then
|
|
|
|
null
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name = "branch-${name}";
|
|
|
|
value = makeJob {
|
|
|
|
description = "Branch ${name}";
|
|
|
|
flake = "git+ssh://git@github.com/${repo}?ref=${ref}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
jobOfPR = id: info: {
|
|
|
|
name = "pr-${id}";
|
|
|
|
value = makeJob {
|
|
|
|
description = "PR ${id}: ${info.title}";
|
|
|
|
flake = "git+ssh://git@github.com/${info.head.repo.full_name}?ref=${info.head.ref}";
|
|
|
|
};
|
2024-04-03 02:34:17 -04:00
|
|
|
};
|
2024-04-20 13:23:49 -04:00
|
|
|
attrsToList = l: builtins.attrValues (builtins.mapAttrs (name: value: { inherit name value; }) l);
|
|
|
|
readJSONFile = f: builtins.fromJSON (builtins.readFile f);
|
|
|
|
mapFilter = f: l: builtins.filter (x: !(isNull x)) (map f l);
|
2024-04-17 20:50:57 -04:00
|
|
|
in
|
2024-04-20 13:23:49 -04:00
|
|
|
# throwJSON = x: throw (builtins.toJSON x);
|
|
|
|
# prJobsets = pkgs.lib.mapAttrs (num: info: {
|
|
|
|
# enabled = 1;
|
|
|
|
# hidden = false;
|
|
|
|
# description = "PR ${num}: ${info.title}";
|
|
|
|
# checkinterval = 60;
|
|
|
|
# schedulingshares = 20;
|
|
|
|
# enableemail = false;
|
|
|
|
# emailoverride = "";
|
|
|
|
# keepnr = 1;
|
|
|
|
# type = 1;
|
|
|
|
# flake = "github:ahuston-0/nix-dotfiles-hydra/pull/${num}/head";
|
|
|
|
# }) prs;
|
|
|
|
# branchJobsets = pkgs.lib.mapAttrs (num: info: {
|
|
|
|
# enabled = 1;
|
|
|
|
# hidden = false;
|
|
|
|
# description = "PR ${num}: ${info.title}";
|
|
|
|
# checkinterval = 60;
|
|
|
|
# schedulingshares = 20;
|
|
|
|
# enableemail = false;
|
|
|
|
# emailoverride = "";
|
|
|
|
# keepnr = 1;
|
|
|
|
# type = 1;
|
|
|
|
# flake = "github:ahuston-0/nix-dotfiles-hydra/pull/${num}/head";
|
|
|
|
# }) branches;
|
|
|
|
# updateJobsets = pkgs.lib.mapAttrs (num: info: {
|
|
|
|
# enabled = 1;
|
|
|
|
# hidden = false;
|
|
|
|
# description = "PR ${num}: ${info.title}";
|
|
|
|
# checkinterval = 60;
|
|
|
|
# schedulingshares = 20;
|
|
|
|
# enableemail = false;
|
|
|
|
# emailoverride = "";
|
|
|
|
# keepnr = 1;
|
|
|
|
# type = 1;
|
|
|
|
# flake = "github:ahuston-0/nix-dotfiles-hydra/pull/${num}/head";
|
|
|
|
# }) prs;
|
|
|
|
# mkFlakeJobset = branch: {
|
|
|
|
# description = "Build ${branch}";
|
|
|
|
# checkinterval = "3600";
|
|
|
|
# enabled = "1";
|
|
|
|
# schedulingshares = 100;
|
|
|
|
# enableemail = false;
|
|
|
|
# emailoverride = "";
|
|
|
|
# keepnr = 3;
|
|
|
|
# hidden = false;
|
|
|
|
# type = 1;
|
|
|
|
# flake = "github:ahuston-0/nix-dotfiles-hydra/tree/${branch}";
|
|
|
|
# };
|
|
|
|
# desc = prJobsets // {
|
|
|
|
# "main" = mkFlakeJobset "main";
|
|
|
|
# "feature-upsync" = mkFlakeJobset "feature/upsync";
|
|
|
|
# };
|
|
|
|
# log = {
|
|
|
|
# pulls = prs;
|
|
|
|
# jobsets = desc;
|
|
|
|
# };
|
2024-04-17 20:50:57 -04:00
|
|
|
{
|
2024-04-20 13:23:49 -04:00
|
|
|
# jobsets = pkgs.runCommand "spec-jobsets.json" { } ''
|
|
|
|
# cat >$out <<EOF
|
|
|
|
# ${builtins.toJSON desc}
|
|
|
|
# EOF
|
|
|
|
# # This is to get nice .jobsets build logs on Hydra
|
|
|
|
# cat >tmp <<EOF
|
|
|
|
# ${builtins.toJSON log}
|
|
|
|
# EOF
|
|
|
|
# ${pkgs.jq}/bin/jq . tmp
|
|
|
|
# '';
|
|
|
|
jobsets = makeSpec (
|
|
|
|
builtins.listToAttrs (map ({ name, value }: jobOfPR name value) (attrsToList (readJSONFile prs)))
|
|
|
|
// builtins.listToAttrs (
|
|
|
|
mapFilter ({ name, value }: jobOfRef name value) (attrsToList (readJSONFile branches))
|
|
|
|
)
|
|
|
|
// builtins.listToAttrs (
|
|
|
|
mapFilter ({ name, value }: jobOfRef name value) (attrsToList (readJSONFile update))
|
|
|
|
)
|
|
|
|
// {
|
|
|
|
main = makeJob {
|
|
|
|
description = "main";
|
|
|
|
flake = "github:${repo}";
|
|
|
|
keepnr = 10;
|
|
|
|
schedulingshares = 100;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
2024-04-03 02:34:17 -04:00
|
|
|
}
|