1 { config, lib, pkgs, ... }:
4 inherit (lib) escapeShellArgs mkEnableOption mkPackageOption mkIf mkOption types;
6 cfg = config.services.mimir;
8 settingsFormat = pkgs.formats.yaml {};
10 options.services.mimir = {
11 enable = mkEnableOption "mimir";
13 configuration = mkOption {
14 type = (pkgs.formats.json {}).type;
17 Specify the configuration for Mimir in Nix.
21 configFile = mkOption {
22 type = types.nullOr types.path;
25 Specify a configuration file that Mimir should use.
29 package = mkPackageOption pkgs "mimir" { };
31 extraFlags = mkOption {
32 type = types.listOf types.str;
34 example = [ "--config.expand-env=true" ];
36 Specify a list of additional command line flags,
37 which get escaped and are then passed to Mimir.
42 config = mkIf cfg.enable {
44 environment.systemPackages = [ cfg.package ];
48 (cfg.configuration == {} -> cfg.configFile != null) &&
49 (cfg.configFile != null -> cfg.configuration == {})
53 'services.mimir.configuration' or
54 'services.mimir.configFile'.
58 systemd.services.mimir = {
59 description = "mimir Service Daemon";
60 wantedBy = [ "multi-user.target" ];
63 conf = if cfg.configFile == null
64 then settingsFormat.generate "config.yaml" cfg.configuration
68 ExecStart = "${cfg.package}/bin/mimir --config.file=${conf} ${escapeShellArgs cfg.extraFlags}";
71 ProtectSystem = "full";
72 DevicePolicy = "closed";
73 NoNewPrivileges = true;
74 WorkingDirectory = "/var/lib/mimir";
75 StateDirectory = "mimir";