mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 23:03:40 +01:00
grafana-mimir: add initial module
This commit is contained in:
parent
8750fbd0e1
commit
a4707b645f
2 changed files with 64 additions and 0 deletions
|
@ -662,6 +662,7 @@
|
|||
./services/monitoring/longview.nix
|
||||
./services/monitoring/mackerel-agent.nix
|
||||
./services/monitoring/metricbeat.nix
|
||||
./services/monitoring/mimir.nix
|
||||
./services/monitoring/monit.nix
|
||||
./services/monitoring/munin.nix
|
||||
./services/monitoring/nagios.nix
|
||||
|
|
63
nixos/modules/services/monitoring/mimir.nix
Normal file
63
nixos/modules/services/monitoring/mimir.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{ 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 "mimir";
|
||||
|
||||
configuration = mkOption {
|
||||
type = (pkgs.formats.json {}).type;
|
||||
default = {};
|
||||
description = ''
|
||||
Specify the configuration for Mimir in Nix.
|
||||
'';
|
||||
};
|
||||
|
||||
configFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
Specify a configuration file that Mimir should use.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
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
|
||||
{
|
||||
ExecStart = "${pkgs.grafana-mimir}/bin/mimir --config.file=${conf}";
|
||||
DynamicUser = true;
|
||||
Restart = "always";
|
||||
ProtectSystem = "full";
|
||||
DevicePolicy = "closed";
|
||||
NoNewPrivileges = true;
|
||||
StateDirectory = "mimir";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue