diff --git a/nixos/modules/services/monitoring/riemann.nix b/nixos/modules/services/monitoring/riemann.nix index fd625e34e013..97ae9e2211af 100644 --- a/nixos/modules/services/monitoring/riemann.nix +++ b/nixos/modules/services/monitoring/riemann.nix @@ -1,23 +1,19 @@ { config, pkgs, lib, ... }: - -with pkgs; -with lib; - let cfg = config.services.riemann; - classpath = concatStringsSep ":" ( - cfg.extraClasspathEntries ++ [ "${riemann}/share/java/riemann.jar" ] + classpath = lib.concatStringsSep ":" ( + cfg.extraClasspathEntries ++ [ "${pkgs.riemann}/share/java/riemann.jar" ] ); - riemannConfig = concatStringsSep "\n" ( + riemannConfig = lib.concatStringsSep "\n" ( [cfg.config] ++ (map (f: ''(load-file "${f}")'') cfg.configFiles) ); - launcher = writeScriptBin "riemann" '' + launcher = pkgs.writeScriptBin "riemann" '' #!/bin/sh - exec ${jdk}/bin/java ${concatStringsSep " " cfg.extraJavaOpts} \ + exec ${pkgs.jdk}/bin/java ${lib.concatStringsSep " " cfg.extraJavaOpts} \ -cp ${classpath} \ riemann.bin ${cfg.configFile} ''; @@ -27,17 +23,17 @@ in { options = { services.riemann = { - enable = mkEnableOption "Riemann network monitoring daemon"; + enable = lib.mkEnableOption "Riemann network monitoring daemon"; - config = mkOption { - type = types.lines; + config = lib.mkOption { + type = lib.types.lines; description = '' Contents of the Riemann configuration file. For more complicated config you should use configFile. ''; }; - configFiles = mkOption { - type = with types; listOf path; + configFiles = lib.mkOption { + type = with lib.types; listOf path; default = []; description = '' Extra files containing Riemann configuration. These files will be @@ -47,22 +43,22 @@ in { use configFile. ''; }; - configFile = mkOption { - type = types.str; + configFile = lib.mkOption { + type = lib.types.str; description = '' A Riemann config file. Any files in the same directory as this file will be added to the classpath by Riemann. ''; }; - extraClasspathEntries = mkOption { - type = with types; listOf str; + extraClasspathEntries = lib.mkOption { + type = with lib.types; listOf str; default = []; description = '' Extra entries added to the Java classpath when running Riemann. ''; }; - extraJavaOpts = mkOption { - type = with types; listOf str; + extraJavaOpts = lib.mkOption { + type = with lib.types; listOf str; default = []; description = '' Extra Java options used when launching Riemann. @@ -71,7 +67,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.groups.riemann.gid = config.ids.gids.riemann; @@ -81,13 +77,13 @@ in { group = "riemann"; }; - services.riemann.configFile = mkDefault ( - writeText "riemann-config.clj" riemannConfig + services.riemann.configFile = lib.mkDefault ( + pkgs.writeText "riemann-config.clj" riemannConfig ); systemd.services.riemann = { wantedBy = [ "multi-user.target" ]; - path = [ inetutils ]; + path = [ pkgs.inetutils ]; serviceConfig = { User = "riemann"; ExecStart = "${launcher}/bin/riemann";