Skip to content

Instantly share code, notes, and snippets.

@ocharles
Last active August 17, 2018 13:55
Show Gist options
  • Save ocharles/86f28b70ad659d389d6a587147576315 to your computer and use it in GitHub Desktop.
Save ocharles/86f28b70ad659d389d6a587147576315 to your computer and use it in GitHub Desktop.
{ nixpkgs ? <nixpkgs>
, declInput ? {}
, pullRequests
}:
let
pkgs = import nixpkgs {};
make-job =
{ description, github }:
let
latestCommit =
builtins.fetchGit {
url = "ssh://git@github.com/${github.owner}/${github.repo}";
ref = github.ref;
};
in
{
inherit description;
enabled = 1;
hidden = false;
nixexprpath = "hydra/jobs.nix";
nixexprinput = "src";
checkinterval = 5;
schedulingshares = 100;
enableemail = false;
emailoverride = "";
keepnr = 3;
inputs = {
src = {
type = "git";
value = "git@github.com:${github.owner}/${github.repo} ${github.ref}";
emailresponsible = false;
};
nixpkgs = {
type = "path";
value = ( import ( latestCommit + "/nix/pkgs" ) {}).path;
emailresponsible = false;
};
ssh-config-file = {
type = "path";
value = "/var/lib/nixbld/ssh_config";
emailresponsible = false;
};
};
};
build-pull-request =
num: info:
{
name = "pr-${num}";
value =
make-job
{
description = "PR #${num}: ${info.title}";
github = {
owner = info.head.repo.owner.login;
repo = info.head.repo.name;
ref = info.head.ref;
revision = info.head.sha;
};
};
};
prJobsets =
pkgs.lib.listToAttrs
( pkgs.lib.mapAttrsToList build-pull-request
(builtins.fromJSON (builtins.readFile pullRequests)));
jobsetAttrs = {
master = make-job {
description = "master";
github = {
owner = "..";
repo = "..";
ref = "master";
};
};
} // prJobsets;
jobsetJson = pkgs.writeText "spec.json" (builtins.toJSON jobsetAttrs);
in
{
jobsets = with pkgs.lib; pkgs.runCommand "spec.json" {} ''
cp ${jobsetJson} $out
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment