1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-25 02:26:19 +03:00
nixpkgs/nixos/modules/services/monitoring/mimir.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

97 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
escapeShellArgs
mkEnableOption
mkPackageOption
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.
'';
};
package = mkPackageOption pkgs "mimir" { };
extraFlags = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "--config.expand-env=true" ];
description = ''
Specify a list of additional command line flags,
which get escaped and are then passed to Mimir.
'';
};
};
config = mkIf cfg.enable {
# for mimirtool
environment.systemPackages = [ cfg.package ];
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 = "${cfg.package}/bin/mimir --config.file=${conf} ${escapeShellArgs cfg.extraFlags}";
DynamicUser = true;
Restart = "always";
ProtectSystem = "full";
DevicePolicy = "closed";
NoNewPrivileges = true;
WorkingDirectory = "/var/lib/mimir";
StateDirectory = "mimir";
};
};
};
}