From 762a9df69ce50ab13f6e9e5943fa603e06c57d8f Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 28 May 2021 02:02:21 +0200 Subject: [PATCH] nixos-module/collectd: add execUser workaround --- nix/nixos-module/collectd/default.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nix/nixos-module/collectd/default.nix b/nix/nixos-module/collectd/default.nix index d2f9628..ebe1e8a 100644 --- a/nix/nixos-module/collectd/default.nix +++ b/nix/nixos-module/collectd/default.nix @@ -13,6 +13,11 @@ let customTypesDb = builtins.toFile "types.db" '' stations value:GAUGE:0:U ''; + inherit (config.services.collectd) user; + execUser = + if user == "root" + then "nobody" + else user; isUpstream = builtins.match "upstream.*" hostName != null || builtins.match "anon.*" hostName != null; @@ -90,11 +95,11 @@ in else maxTimeout ) 180 (builtins.attrNames config.site.net); in '' - Exec "nobody" "${pkgs.ruby}/bin/ruby" "${./dhcpcount.rb}" "${toString maxTimeout}" + Exec "${execUser}" "${pkgs.ruby}/bin/ruby" "${./dhcpcount.rb}" "${toString maxTimeout}" ''; }) (lib.optionalAttrs config.services.unbound.enable { plugins.exec = '' - Exec "nobody" "${pkgs.ruby}/bin/ruby" "${./unbound.rb}" + Exec "${execUser}" "${pkgs.ruby}/bin/ruby" "${./unbound.rb}" ''; }) (lib.optionalAttrs hasStarlink { plugins.exec = ''