nixos/services.riemann: remove with lib;
This commit is contained in:
parent
36b176c8e3
commit
a7f917375f
@ -1,23 +1,19 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
with pkgs;
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.riemann;
|
cfg = config.services.riemann;
|
||||||
|
|
||||||
classpath = concatStringsSep ":" (
|
classpath = lib.concatStringsSep ":" (
|
||||||
cfg.extraClasspathEntries ++ [ "${riemann}/share/java/riemann.jar" ]
|
cfg.extraClasspathEntries ++ [ "${pkgs.riemann}/share/java/riemann.jar" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
riemannConfig = concatStringsSep "\n" (
|
riemannConfig = lib.concatStringsSep "\n" (
|
||||||
[cfg.config] ++ (map (f: ''(load-file "${f}")'') cfg.configFiles)
|
[cfg.config] ++ (map (f: ''(load-file "${f}")'') cfg.configFiles)
|
||||||
);
|
);
|
||||||
|
|
||||||
launcher = writeScriptBin "riemann" ''
|
launcher = pkgs.writeScriptBin "riemann" ''
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec ${jdk}/bin/java ${concatStringsSep " " cfg.extraJavaOpts} \
|
exec ${pkgs.jdk}/bin/java ${lib.concatStringsSep " " cfg.extraJavaOpts} \
|
||||||
-cp ${classpath} \
|
-cp ${classpath} \
|
||||||
riemann.bin ${cfg.configFile}
|
riemann.bin ${cfg.configFile}
|
||||||
'';
|
'';
|
||||||
@ -27,17 +23,17 @@ in {
|
|||||||
options = {
|
options = {
|
||||||
|
|
||||||
services.riemann = {
|
services.riemann = {
|
||||||
enable = mkEnableOption "Riemann network monitoring daemon";
|
enable = lib.mkEnableOption "Riemann network monitoring daemon";
|
||||||
|
|
||||||
config = mkOption {
|
config = lib.mkOption {
|
||||||
type = types.lines;
|
type = lib.types.lines;
|
||||||
description = ''
|
description = ''
|
||||||
Contents of the Riemann configuration file. For more complicated
|
Contents of the Riemann configuration file. For more complicated
|
||||||
config you should use configFile.
|
config you should use configFile.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
configFiles = mkOption {
|
configFiles = lib.mkOption {
|
||||||
type = with types; listOf path;
|
type = with lib.types; listOf path;
|
||||||
default = [];
|
default = [];
|
||||||
description = ''
|
description = ''
|
||||||
Extra files containing Riemann configuration. These files will be
|
Extra files containing Riemann configuration. These files will be
|
||||||
@ -47,22 +43,22 @@ in {
|
|||||||
use configFile.
|
use configFile.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
configFile = mkOption {
|
configFile = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
description = ''
|
description = ''
|
||||||
A Riemann config file. Any files in the same directory as this file
|
A Riemann config file. Any files in the same directory as this file
|
||||||
will be added to the classpath by Riemann.
|
will be added to the classpath by Riemann.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
extraClasspathEntries = mkOption {
|
extraClasspathEntries = lib.mkOption {
|
||||||
type = with types; listOf str;
|
type = with lib.types; listOf str;
|
||||||
default = [];
|
default = [];
|
||||||
description = ''
|
description = ''
|
||||||
Extra entries added to the Java classpath when running Riemann.
|
Extra entries added to the Java classpath when running Riemann.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
extraJavaOpts = mkOption {
|
extraJavaOpts = lib.mkOption {
|
||||||
type = with types; listOf str;
|
type = with lib.types; listOf str;
|
||||||
default = [];
|
default = [];
|
||||||
description = ''
|
description = ''
|
||||||
Extra Java options used when launching Riemann.
|
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;
|
users.groups.riemann.gid = config.ids.gids.riemann;
|
||||||
|
|
||||||
@ -81,13 +77,13 @@ in {
|
|||||||
group = "riemann";
|
group = "riemann";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.riemann.configFile = mkDefault (
|
services.riemann.configFile = lib.mkDefault (
|
||||||
writeText "riemann-config.clj" riemannConfig
|
pkgs.writeText "riemann-config.clj" riemannConfig
|
||||||
);
|
);
|
||||||
|
|
||||||
systemd.services.riemann = {
|
systemd.services.riemann = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [ inetutils ];
|
path = [ pkgs.inetutils ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "riemann";
|
User = "riemann";
|
||||||
ExecStart = "${launcher}/bin/riemann";
|
ExecStart = "${launcher}/bin/riemann";
|
||||||
|
Loading…
Reference in New Issue
Block a user