git.iko.soy/typeable/nixpkgs
on master help sign in
lighttpd: add collectd submodule
commit99b8d5ebe67a5aeb97c4a4202441d91c7d469e12 authorVolth <volth@webmaster.ms> dateThu 29 Jun 2017, 22:21 (9 years ago) parentdc9f69c
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
@@ -586,6 +586,7 @@
586586 ./services/web-servers/fcgiwrap.nix
587587 ./services/web-servers/jboss/default.nix
588588 ./services/web-servers/lighttpd/cgit.nix
589+ ./services/web-servers/lighttpd/collectd.nix
589590 ./services/web-servers/lighttpd/default.nix
590591 ./services/web-servers/lighttpd/gitweb.nix
591592 ./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+}