diff --git a/nixos/modules/services/monitoring/karma.nix b/nixos/modules/services/monitoring/karma.nix index b7ec5e4ae6fb..2300067719ff 100644 --- a/nixos/modules/services/monitoring/karma.nix +++ b/nixos/modules/services/monitoring/karma.nix @@ -1,17 +1,16 @@ { config, pkgs, lib, ... }: -with lib; let cfg = config.services.karma; yaml = pkgs.formats.yaml { }; in { options.services.karma = { - enable = mkEnableOption "the Karma dashboard service"; + enable = lib.mkEnableOption "the Karma dashboard service"; - package = mkPackageOption pkgs "karma" { }; + package = lib.mkPackageOption pkgs "karma" { }; - configFile = mkOption { - type = types.path; + configFile = lib.mkOption { + type = lib.types.path; default = yaml.generate "karma.yaml" cfg.settings; defaultText = "A configuration file generated from the provided nix attributes settings option."; description = '' @@ -20,8 +19,8 @@ in example = "/etc/karma/karma.conf"; }; - environment = mkOption { - type = with types; attrsOf str; + environment = lib.mkOption { + type = with lib.types; attrsOf str; default = {}; description = '' Additional environment variables to provide to karma. @@ -32,16 +31,16 @@ in }; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to open ports in the firewall needed for karma to function. ''; }; - extraOptions = mkOption { - type = with types; listOf str; + extraOptions = lib.mkOption { + type = with lib.types; listOf str; default = []; description = '' Extra command line options. @@ -51,13 +50,13 @@ in ]; }; - settings = mkOption { - type = types.submodule { + settings = lib.mkOption { + type = lib.types.submodule { freeformType = yaml.type; options.listen = { - address = mkOption { - type = types.str; + address = lib.mkOption { + type = lib.types.str; default = "127.0.0.1"; description = '' Hostname or IP to listen on. @@ -65,8 +64,8 @@ in example = "[::]"; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8080; description = '' HTTP port to listen on. @@ -104,7 +103,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.karma = { description = "Alert dashboard for Prometheus Alertmanager"; wantedBy = [ "multi-user.target" ]; @@ -113,9 +112,9 @@ in Type = "simple"; DynamicUser = true; Restart = "on-failure"; - ExecStart = "${pkgs.karma}/bin/karma --config.file ${cfg.configFile} ${concatStringsSep " " cfg.extraOptions}"; + ExecStart = "${pkgs.karma}/bin/karma --config.file ${cfg.configFile} ${lib.concatStringsSep " " cfg.extraOptions}"; }; }; - networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.settings.listen.port ]; + networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.settings.listen.port ]; }; }