2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
105 lines
2.6 KiB
Nix
105 lines
2.6 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with pkgs;
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.riemann;
|
|
|
|
classpath = concatStringsSep ":" (
|
|
cfg.extraClasspathEntries ++ [ "${riemann}/share/java/riemann.jar" ]
|
|
);
|
|
|
|
riemannConfig = concatStringsSep "\n" (
|
|
[cfg.config] ++ (map (f: ''(load-file "${f}")'') cfg.configFiles)
|
|
);
|
|
|
|
launcher = writeScriptBin "riemann" ''
|
|
#!/bin/sh
|
|
exec ${jdk}/bin/java ${concatStringsSep " " cfg.extraJavaOpts} \
|
|
-cp ${classpath} \
|
|
riemann.bin ${cfg.configFile}
|
|
'';
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.riemann = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Enable the Riemann network monitoring daemon.
|
|
'';
|
|
};
|
|
config = mkOption {
|
|
type = types.lines;
|
|
description = lib.mdDoc ''
|
|
Contents of the Riemann configuration file. For more complicated
|
|
config you should use configFile.
|
|
'';
|
|
};
|
|
configFiles = mkOption {
|
|
type = with types; listOf path;
|
|
default = [];
|
|
description = lib.mdDoc ''
|
|
Extra files containing Riemann configuration. These files will be
|
|
loaded at runtime by Riemann (with Clojure's
|
|
`load-file` function) at the end of the
|
|
configuration if you use the config option, this is ignored if you
|
|
use configFile.
|
|
'';
|
|
};
|
|
configFile = mkOption {
|
|
type = types.str;
|
|
description = lib.mdDoc ''
|
|
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;
|
|
default = [];
|
|
description = lib.mdDoc ''
|
|
Extra entries added to the Java classpath when running Riemann.
|
|
'';
|
|
};
|
|
extraJavaOpts = mkOption {
|
|
type = with types; listOf str;
|
|
default = [];
|
|
description = lib.mdDoc ''
|
|
Extra Java options used when launching Riemann.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.groups.riemann.gid = config.ids.gids.riemann;
|
|
|
|
users.users.riemann = {
|
|
description = "riemann daemon user";
|
|
uid = config.ids.uids.riemann;
|
|
group = "riemann";
|
|
};
|
|
|
|
services.riemann.configFile = mkDefault (
|
|
writeText "riemann-config.clj" riemannConfig
|
|
);
|
|
|
|
systemd.services.riemann = {
|
|
wantedBy = [ "multi-user.target" ];
|
|
path = [ inetutils ];
|
|
serviceConfig = {
|
|
User = "riemann";
|
|
ExecStart = "${launcher}/bin/riemann";
|
|
};
|
|
serviceConfig.LimitNOFILE = 65536;
|
|
};
|
|
|
|
};
|
|
|
|
}
|