at master 2.1 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.inspircd; 10 11 configFile = pkgs.writeText "inspircd.conf" cfg.config; 12 13in 14{ 15 meta = { 16 maintainers = [ lib.maintainers.sternenseemann ]; 17 }; 18 19 options = { 20 services.inspircd = { 21 enable = lib.mkEnableOption "InspIRCd"; 22 23 package = lib.mkOption { 24 type = lib.types.package; 25 default = pkgs.inspircd; 26 defaultText = lib.literalExpression "pkgs.inspircd"; 27 example = lib.literalExpression "pkgs.inspircdMinimal"; 28 description = '' 29 The InspIRCd package to use. This is mainly useful 30 to specify an overridden version of the 31 `pkgs.inspircd` dervivation, for 32 example if you want to use a more minimal InspIRCd 33 distribution with less modules enabled or with 34 modules enabled which can't be distributed in binary 35 form due to licensing issues. 36 ''; 37 }; 38 39 config = lib.mkOption { 40 type = lib.types.lines; 41 description = '' 42 Verbatim `inspircd.conf` file. 43 For a list of options, consult the 44 [InspIRCd documentation](https://docs.inspircd.org/3/configuration/), the 45 [Module documentation](https://docs.inspircd.org/3/modules/) 46 and the example configuration files distributed 47 with `pkgs.inspircd.doc` 48 ''; 49 }; 50 }; 51 }; 52 53 config = lib.mkIf cfg.enable { 54 systemd.services.inspircd = { 55 description = "InspIRCd - the stable, high-performance and modular Internet Relay Chat Daemon"; 56 unitConfig.Documentation = "https://docs.inspircd.org"; 57 wantedBy = [ "multi-user.target" ]; 58 59 after = [ 60 "network.target" 61 "network-online.target" 62 ]; 63 wants = [ "network-online.target" ]; 64 65 serviceConfig = { 66 Type = "simple"; 67 ExecStart = '' 68 ${lib.getBin cfg.package}/bin/inspircd --config ${configFile} --nofork --nopid 69 ''; 70 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 71 Restart = "on-failure"; 72 DynamicUser = true; 73 }; 74 }; 75 }; 76}