79 lines
1.9 KiB
Nix
79 lines
1.9 KiB
Nix
|
{ config, lib, pkgs, ... }:
|
||
|
|
||
|
with lib;
|
||
|
|
||
|
let
|
||
|
|
||
|
cfg = config.services.update-from-hydra;
|
||
|
|
||
|
repositoryOpts = { config, ... }@moduleAttrs: {
|
||
|
options = {
|
||
|
|
||
|
updatePath = mkOption {
|
||
|
type = types.path;
|
||
|
description = ''
|
||
|
Path to the symlink pointing to the hydra build output store path
|
||
|
'';
|
||
|
};
|
||
|
|
||
|
hydraUrl = mkOption {
|
||
|
type = types.str;
|
||
|
example = "https://hydra.clerie.de/job/clerie/chaosevents/packages.x86_64-linux.chaosevents/latest-finished";
|
||
|
description = ''
|
||
|
Url to Hydra
|
||
|
'';
|
||
|
};
|
||
|
|
||
|
storeUri = mkOption {
|
||
|
type = types.str;
|
||
|
description = ''
|
||
|
Uri to nix store from which the store path build in Hydra can be copied from
|
||
|
'';
|
||
|
};
|
||
|
|
||
|
startAt = mkOption {
|
||
|
type = with types; either str (listOf str);
|
||
|
default = "hourly";
|
||
|
description = ''
|
||
|
How often the directory should be updated.
|
||
|
Format specified by `systemd.time 7`.
|
||
|
This value can also be a list of `systemd.time 7` formatted
|
||
|
strings, in which case the service will be started on multiple
|
||
|
schedules.
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
|
||
|
in {
|
||
|
options = {
|
||
|
services.update-from-hydra = {
|
||
|
|
||
|
enable = mkEnableOption "Make a hydra build output availiable with a symlink and keep it up to date";
|
||
|
|
||
|
paths = mkOption {
|
||
|
type = with types; attrsOf (submodule repositoryOpts);
|
||
|
default = {};
|
||
|
};
|
||
|
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
systemd.services = (mapAttrs' (name: path: let
|
||
|
in nameValuePair "update-from-hydra-${name}" {
|
||
|
inherit (path) startAt;
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
|
serviceConfig = {
|
||
|
Type = "oneshot";
|
||
|
};
|
||
|
path = [ pkgs.nix ];
|
||
|
script = ''
|
||
|
${pkgs.update-from-hydra}/bin/update-from-hydra "${path.hydraUrl}" "${path.updatePath}" "${path.storeUri}"
|
||
|
'';
|
||
|
}
|
||
|
) cfg.paths);
|
||
|
};
|
||
|
}
|
||
|
|