git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #26978 from volth/lighttpd-collectd-submodule

lighttpd: add collectd submodule

commitc2576ac2d37882709be41227202a1dc691b22192 authorJoachim F <joachifm@users.noreply.github.com> dateSun 2 Jul 2017, 11:49 (9 years ago) parente20364a99b8d5e
2 files changed+59
nixos/modules/module-list.nix+1 nixos/modules/services/web-servers/lighttpd/collectd.nix+58
nixos/modules/module-list.nix+1
@@ -587,6 +587,7 @@
587587 ./services/web-servers/fcgiwrap.nix
588588 ./services/web-servers/jboss/default.nix
589589 ./services/web-servers/lighttpd/cgit.nix
590+ ./services/web-servers/lighttpd/collectd.nix
590591 ./services/web-servers/lighttpd/default.nix
591592 ./services/web-servers/lighttpd/gitweb.nix
592593 ./services/web-servers/lighttpd/inginious.nix
nixos/modules/services/web-servers/lighttpd/collectd.nixnew file+58
@@ -0,0 +1,58 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.lighttpd.collectd;
7+
8+ collectionConf = pkgs.writeText "collection.conf" ''
9+ datadir: "${config.services.collectd.dataDir}"
10+ libdir: "${config.services.collectd.package}/lib/collectd"
11+ '';
12+
13+ defaultCollectionCgi = config.services.collectd.package.overrideDerivation(old: {
14+ name = "collection.cgi";
15+ configurePhase = "true";
16+ buildPhase = "true";
17+ installPhase = ''
18+ substituteInPlace contrib/collection.cgi --replace '"/etc/collection.conf"' '$ENV{COLLECTION_CONF}'
19+ cp contrib/collection.cgi $out
20+ '';
21+ });
22+in
23+{
24+
25+ options.services.lighttpd.collectd = {
26+
27+ enable = mkEnableOption "collectd subservice accessible at http://yourserver/collectd";
28+
29+ collectionCgi = mkOption {
30+ type = types.path;
31+ default = defaultCollectionCgi;
32+ description = ''
33+ Path to collection.cgi script from (collectd sources)/contrib/collection.cgi
34+ This option allows to use a customized version
35+ '';
36+ };
37+ };
38+
39+ config = mkIf cfg.enable {
40+ services.lighttpd.enableModules = [ "mod_cgi" "mod_alias" "mod_setenv" ];
41+
42+ services.lighttpd.extraConfig = ''
43+ $HTTP["url"] =~ "^/collectd" {
44+ cgi.assign = (
45+ ".cgi" => "${pkgs.perl}/bin/perl"
46+ )
47+ alias.url = (
48+ "/collectd" => "${cfg.collectionCgi}"
49+ )
50+ setenv.add-environment = (
51+ "PERL5LIB" => "${with pkgs; lib.makePerlPath [ perlPackages.CGI perlPackages.HTMLParser perlPackages.URI rrdtool ]}",
52+ "COLLECTION_CONF" => "${collectionConf}"
53+ )
54+ }
55+ '';
56+ };
57+
58+}