2023-09-02 21:47:45 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.update-from-hydra;
|
|
|
|
|
|
|
|
repositoryOpts = { config, ... }@moduleAttrs: {
|
|
|
|
options = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "Make a hydra build output availiable with a symlink and keep it up to date";
|
|
|
|
|
|
|
|
resultPath = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
description = ''
|
|
|
|
Path to the symlink pointing to the hydra build output store path
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hydraUrl = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hydraProject = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Hydra project name
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hydraJobset = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Hydra jobset name
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hydraJob = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
Hydra job name
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-09-09 14:15:24 +02:00
|
|
|
buildOutput = mkOption {
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
Build output name
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-09-02 21:47:45 +02:00
|
|
|
nixStoreUri = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = ''
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
startAt = mkOption {
|
|
|
|
type = with types; either str (listOf str);
|
|
|
|
default = "hourly";
|
|
|
|
description = ''
|
|
|
|
How often the directory should be updated.
|
|
|
|
Formatspecified 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 = {
|
|
|
|
|
|
|
|
paths = mkOption {
|
|
|
|
type = with types; attrsOf (submodule repositoryOpts);
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
|
|
|
systemd.services = (mapAttrs' (name: path: nameValuePair "update-from-hydra-${name}" (mkIf path.enable {
|
|
|
|
inherit (path) startAt;
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
script = ''
|
2023-09-09 14:15:24 +02:00
|
|
|
${pkgs.update-from-hydra}/bin/update-from-hydra --hydra-url "${path.hydraUrl}" --hydra-project "${path.hydraProject}" --hydra-jobset "${path.hydraJobset}" --hydra-job "${path.hydraJob}" ${optionalString (path.buildOutput != null) "--build-output ${path.buildOutput}"} --nix-store-uri "${path.nixStoreUri}" --gcroot-name "${name}" "${path.resultPath}"
|
2023-09-02 21:47:45 +02:00
|
|
|
'';
|
|
|
|
})
|
|
|
|
) cfg.paths);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|