From 0a750e0f390cb726f2dbc3099beb78a7e21a12a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Thu, 24 Jul 2014 11:45:07 +0200 Subject: [PATCH] nixos/munin: change activationScript to preStart script All activation scripts run in serial upon boot and nixos-rebuild switch etc., in contrast to preStart which run before a service starts, and can run in parallel with other services. The munin(-node) activation script is particularly slow. Change it to a preStart script so that it can run in parallel with other services and not slow down boot (or nixos-rebuild switch). This reduces (repeated) "nixos-rebuild test" time from ~16 seconds to ~8 on my (old) laptop. --- nixos/modules/services/monitoring/munin.nix | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/monitoring/munin.nix b/nixos/modules/services/monitoring/munin.nix index 966c2eca282a..21840bc67e8f 100644 --- a/nixos/modules/services/monitoring/munin.nix +++ b/nixos/modules/services/monitoring/munin.nix @@ -189,19 +189,18 @@ in wantedBy = [ "multi-user.target" ]; path = [ pkgs.munin ]; environment.MUNIN_PLUGSTATE = "/var/run/munin"; + preStart = '' + echo "updating munin plugins..." + + mkdir -p /etc/munin/plugins + rm -rf /etc/munin/plugins/* + PATH="/run/current-system/sw/bin:/run/current-system/sw/sbin" ${pkgs.munin}/sbin/munin-node-configure --shell --families contrib,auto,manual --config ${nodeConf} --libdir=${muninPlugins} --servicedir=/etc/munin/plugins 2>/dev/null | ${pkgs.bash}/bin/bash + ''; serviceConfig = { ExecStart = "${pkgs.munin}/sbin/munin-node --config ${nodeConf} --servicedir /etc/munin/plugins/"; }; }; - system.activationScripts.munin-node = '' - echo "updating munin plugins..." - - mkdir -p /etc/munin/plugins - rm -rf /etc/munin/plugins/* - PATH="/run/current-system/sw/bin:/run/current-system/sw/sbin" ${pkgs.munin}/sbin/munin-node-configure --shell --families contrib,auto,manual --config ${nodeConf} --libdir=${muninPlugins} --servicedir=/etc/munin/plugins 2>/dev/null | ${pkgs.bash}/bin/bash - ''; - }) (mkIf cronCfg.enable { services.cron.systemCronJobs = [