-
-
Save ocharles/86f28b70ad659d389d6a587147576315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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