2022-04-29 01:11:19 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) escapeShellArgs mkEnableOption mkIf mkOption types;
|
|
|
|
|
|
|
|
cfg = config.services.mimir;
|
|
|
|
|
|
|
|
settingsFormat = pkgs.formats.yaml {};
|
|
|
|
in {
|
|
|
|
options.services.mimir = {
|
2022-08-28 21:18:44 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "mimir");
|
2022-04-29 01:11:19 +02:00
|
|
|
|
|
|
|
configuration = mkOption {
|
|
|
|
type = (pkgs.formats.json {}).type;
|
|
|
|
default = {};
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-04-29 01:11:19 +02:00
|
|
|
Specify the configuration for Mimir in Nix.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
configFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc ''
|
2022-04-29 01:11:19 +02:00
|
|
|
Specify a configuration file that Mimir should use.
|
|
|
|
'';
|
|
|
|
};
|
2022-11-06 02:16:51 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.mimir;
|
|
|
|
defaultText = lib.literalExpression "pkgs.mimir";
|
|
|
|
type = types.package;
|
|
|
|
description = lib.mdDoc ''Mimir package to use.'';
|
|
|
|
};
|
2022-04-29 01:11:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2022-05-29 09:47:13 +02:00
|
|
|
# for mimirtool
|
|
|
|
environment.systemPackages = [ pkgs.mimir ];
|
|
|
|
|
2022-04-29 01:11:19 +02:00
|
|
|
assertions = [{
|
|
|
|
assertion = (
|
|
|
|
(cfg.configuration == {} -> cfg.configFile != null) &&
|
|
|
|
(cfg.configFile != null -> cfg.configuration == {})
|
|
|
|
);
|
|
|
|
message = ''
|
|
|
|
Please specify either
|
|
|
|
'services.mimir.configuration' or
|
|
|
|
'services.mimir.configFile'.
|
|
|
|
'';
|
|
|
|
}];
|
|
|
|
|
|
|
|
systemd.services.mimir = {
|
|
|
|
description = "mimir Service Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = let
|
|
|
|
conf = if cfg.configFile == null
|
|
|
|
then settingsFormat.generate "config.yaml" cfg.configuration
|
|
|
|
else cfg.configFile;
|
|
|
|
in
|
|
|
|
{
|
2022-11-06 02:16:51 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/mimir --config.file=${conf}";
|
2022-04-29 01:11:19 +02:00
|
|
|
DynamicUser = true;
|
|
|
|
Restart = "always";
|
|
|
|
ProtectSystem = "full";
|
|
|
|
DevicePolicy = "closed";
|
|
|
|
NoNewPrivileges = true;
|
2022-05-28 22:06:22 +02:00
|
|
|
WorkingDirectory = "/var/lib/mimir";
|
2022-04-29 01:11:19 +02:00
|
|
|
StateDirectory = "mimir";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|