2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ...}:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.hail;
|
|
|
|
in {
|
|
|
|
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options.services.hail = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enables the Hail Auto Update Service. Hail can automatically deploy artifacts
|
2022-12-28 21:21:41 +00:00
|
|
|
built by a Hydra Continuous Integration server. A common use case is to provide
|
|
|
|
continuous deployment for single services or a full NixOS configuration.'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
profile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "hail-profile";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The name of the Nix profile used by Hail.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
hydraJobUri = mkOption {
|
|
|
|
type = types.str;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The URI of the Hydra Job.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
netrc = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "The netrc file to use when fetching data from Hydra.";
|
2020-04-24 23:36:52 +00:00
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.haskellPackages.hail;
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression "pkgs.haskellPackages.hail";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Hail package to use.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.hail = {
|
|
|
|
description = "Hail Auto Update Service";
|
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = with pkgs; [ nix ];
|
|
|
|
environment = {
|
|
|
|
HOME = "/var/lib/empty";
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${cfg.package}/bin/hail --profile ${cfg.profile} --job-uri ${cfg.hydraJobUri}"
|
|
|
|
+ lib.optionalString (cfg.netrc != null) " --netrc-file ${cfg.netrc}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|