3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/modules/services/monitoring/mimir.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.7 KiB
Nix
Raw Normal View History

2022-04-29 00:11:19 +01:00
{ config, lib, pkgs, ... }:
let
inherit (lib) escapeShellArgs mkEnableOption mkIf mkOption types;
cfg = config.services.mimir;
settingsFormat = pkgs.formats.yaml {};
in {
options.services.mimir = {
enable = mkEnableOption (lib.mdDoc "mimir");
2022-04-29 00:11:19 +01:00
configuration = mkOption {
type = (pkgs.formats.json {}).type;
default = {};
description = lib.mdDoc ''
2022-04-29 00:11:19 +01:00
Specify the configuration for Mimir in Nix.
'';
};
configFile = mkOption {
type = types.nullOr types.path;
default = null;
description = lib.mdDoc ''
2022-04-29 00:11:19 +01:00
Specify a configuration file that Mimir should use.
'';
};
};
config = mkIf cfg.enable {
# for mimirtool
environment.systemPackages = [ pkgs.mimir ];
2022-04-29 00:11:19 +01: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-06-07 11:53:15 +01:00
ExecStart = "${pkgs.mimir}/bin/mimir --config.file=${conf}";
2022-04-29 00:11:19 +01:00
DynamicUser = true;
Restart = "always";
ProtectSystem = "full";
DevicePolicy = "closed";
NoNewPrivileges = true;
WorkingDirectory = "/var/lib/mimir";
2022-04-29 00:11:19 +01:00
StateDirectory = "mimir";
};
};
};
}