at 16.09-beta 1.3 kB view raw
1{ config, pkgs, lib, ... }: 2 3with pkgs; 4with lib; 5 6let 7 8 cfg = config.services.riemann-tools; 9 10 riemannHost = "${cfg.riemannHost}"; 11 12 healthLauncher = writeScriptBin "riemann-health" '' 13 #!/bin/sh 14 exec ${pkgs.riemann-tools}/bin/riemann-health --host ${riemannHost} 15 ''; 16 17 18in { 19 20 options = { 21 22 services.riemann-tools = { 23 enableHealth = mkOption { 24 type = types.bool; 25 default = false; 26 description = '' 27 Enable the riemann-health daemon. 28 ''; 29 }; 30 riemannHost = mkOption { 31 type = types.str; 32 default = "127.0.0.1"; 33 description = '' 34 Address of the host riemann node. Defaults to localhost. 35 ''; 36 }; 37 }; 38 39 }; 40 41 config = mkIf cfg.enableHealth { 42 43 users.extraGroups.riemanntools.gid = config.ids.gids.riemanntools; 44 45 users.extraUsers.riemanntools = { 46 description = "riemann-tools daemon user"; 47 uid = config.ids.uids.riemanntools; 48 group = "riemanntools"; 49 }; 50 51 systemd.services.riemann-health = { 52 wantedBy = [ "multi-user.target" ]; 53 serviceConfig = { 54 User = "riemanntools"; 55 ExecStart = "${healthLauncher}/bin/riemann-health"; 56 PermissionsStartOnly = true; 57 }; 58 }; 59 60 }; 61 62}