at 17.09-beta 1.2 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.ngircd; 7 8 configFile = pkgs.stdenv.mkDerivation { 9 name = "ngircd.conf"; 10 11 text = cfg.config; 12 13 preferLocalBuild = true; 14 15 buildCommand = '' 16 echo -n "$text" > $out 17 ${cfg.package}/sbin/ngircd --config $out --configtest 18 ''; 19 }; 20in { 21 options = { 22 services.ngircd = { 23 enable = mkEnableOption "the ngircd IRC server"; 24 25 config = mkOption { 26 description = "The ngircd configuration (see ngircd.conf(5))."; 27 28 type = types.lines; 29 }; 30 31 package = mkOption { 32 description = "The ngircd package."; 33 34 type = types.package; 35 36 default = pkgs.ngircd; 37 defaultText = "pkgs.ngircd"; 38 }; 39 }; 40 }; 41 42 config = mkIf cfg.enable { 43 #!!! TODO: Use ExecReload (see https://github.com/NixOS/nixpkgs/issues/1988) 44 systemd.services.ngircd = { 45 description = "The ngircd IRC server"; 46 47 wantedBy = [ "multi-user.target" ]; 48 49 serviceConfig.ExecStart = "${cfg.package}/sbin/ngircd --config ${configFile} --nodaemon"; 50 51 serviceConfig.User = "ngircd"; 52 }; 53 54 users.extraUsers.ngircd = { 55 uid = config.ids.uids.ngircd; 56 description = "ngircd user."; 57 }; 58 }; 59}