Get hydra changes ready for RAD-development

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
ahuston-0 2024-04-20 16:45:37 -04:00 committed by Alice Huston
parent 3be9962a87
commit 76b6547ebe
3 changed files with 19 additions and 35 deletions

View File

@ -2,12 +2,12 @@
nixpkgs, nixpkgs,
pulls, pulls,
branches, branches,
... ...
}: }:
let let
pkgs = import nixpkgs { }; pkgs = import nixpkgs { };
# create the json spec for the jobset
makeSpec = makeSpec =
contents: contents:
builtins.derivation { builtins.derivation {
@ -26,8 +26,9 @@ let
prs = readJSONFile pulls; prs = readJSONFile pulls;
refs = readJSONFile branches; refs = readJSONFile branches;
repo = "ahuston-0/nix-dotfiles-hydra"; repo = "RAD-development/nix-dotfiles";
# template for creating a job
makeJob = makeJob =
{ {
schedulingshares ? 10, schedulingshares ? 10,
@ -49,6 +50,8 @@ let
enableemail = false; enableemail = false;
emailoverride = ""; emailoverride = "";
}; };
# Create a hydra job for a branch
jobOfRef = jobOfRef =
name: name:
{ ref, ... }: { ref, ... }:
@ -62,6 +65,8 @@ let
flake = "git+ssh://git@github.com/${repo}?ref=${ref}"; flake = "git+ssh://git@github.com/${repo}?ref=${ref}";
}; };
}; };
# Create a hydra job for a PR
jobOfPR = id: info: { jobOfPR = id: info: {
name = "pr-${id}"; name = "pr-${id}";
value = makeJob { value = makeJob {
@ -69,35 +74,21 @@ let
flake = "git+ssh://git@github.com/${info.head.repo.full_name}?ref=${info.head.ref}"; flake = "git+ssh://git@github.com/${info.head.repo.full_name}?ref=${info.head.ref}";
}; };
}; };
# some utility functions
# converts json to name/value dicts
attrsToList = l: builtins.attrValues (builtins.mapAttrs (name: value: { inherit name value; }) l); attrsToList = l: builtins.attrValues (builtins.mapAttrs (name: value: { inherit name value; }) l);
# wrapper function for reading json from file
readJSONFile = f: builtins.fromJSON (builtins.readFile f); readJSONFile = f: builtins.fromJSON (builtins.readFile f);
# remove null values from a set, in-case of branches that don't exist
mapFilter = f: l: builtins.filter (x: !(isNull x)) (map f l); mapFilter = f: l: builtins.filter (x: !(isNull x)) (map f l);
# Create job set from PRs and branches
jobs = makeSpec ( jobs = makeSpec (
builtins.listToAttrs (map ({ name, value }: jobOfPR name value) (attrsToList prs)) builtins.listToAttrs (map ({ name, value }: jobOfPR name value) (attrsToList prs))
// builtins.listToAttrs (mapFilter ({ name, value }: jobOfRef name value) (attrsToList refs)) // builtins.listToAttrs (mapFilter ({ name, value }: jobOfRef name value) (attrsToList refs))
// {
main = makeJob {
description = "main";
flake = "github:${repo}";
keepnr = 10;
schedulingshares = 100;
};
}
); );
log = {
jobsets = jobs;
};
in in
{ {
jobsets = jobs; jobsets = jobs;
# // pkgs.runCommand "spec-jobsets.json" { } ''
# cat >$out <<EOF
# ${jobs}
# EOF
# # This is to get nice .jobsets build logs on Hydra
# cat >tmp <<EOF
# ${builtins.toJSON log}
# EOF
# ${pkgs.jq}/bin/jq . tmp
# '';
} }

View File

@ -1,7 +1,7 @@
{ {
"enabled": 1, "enabled": 1,
"hidden": false, "hidden": false,
"description": "system flake", "description": "RAD Development infrastructure",
"nixexprinput": "nixexpr", "nixexprinput": "nixexpr",
"nixexprpath": "hydra/jobsets.nix", "nixexprpath": "hydra/jobsets.nix",
"checkinterval": 60, "checkinterval": 60,
@ -12,7 +12,7 @@
"type": 0, "type": 0,
"inputs": { "inputs": {
"nixexpr": { "nixexpr": {
"value": "https://github.com/ahuston-0/nix-dotfiles-hydra main", "value": "https://github.com/RAD-development/nix-dotfiles main",
"type": "git", "type": "git",
"emailresponsible": false "emailresponsible": false
}, },
@ -23,12 +23,12 @@
}, },
"pulls": { "pulls": {
"type": "githubpulls", "type": "githubpulls",
"value": "ahuston-0 nix-dotfiles-hydra", "value": "RAD-development nix-dotfiles",
"emailresponsible": false "emailresponsible": false
}, },
"branches": { "branches": {
"type": "github_refs", "type": "github_refs",
"value": "ahuston-0 nix-dotfiles-hydra heads -", "value": "RAD-development nix-dotfiles heads -",
"emailresponsible": false "emailresponsible": false
} }
} }

View File

@ -1,9 +1,4 @@
{ { config, pkgs, ... }:
config,
lib,
pkgs,
...
}:
let let
keygen = key: { keygen = key: {
"${key}" = { "${key}" = {
@ -240,8 +235,6 @@ in
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINHtwvfXg/QFjMAjC4JRjlMAaGPgEfSyhpprNpqbGSJn hydra-queue-runner@palatine-hill" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINHtwvfXg/QFjMAjC4JRjlMAaGPgEfSyhpprNpqbGSJn hydra-queue-runner@palatine-hill"
]; ];
system.autoUpgrade.flake = lib.mkForce "github:ahuston-0/nix-dotfiles-hydra";
nix.gc.options = "--delete-older-than 150d"; nix.gc.options = "--delete-older-than 150d";
sops = { sops = {