at v192 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 }; 38 }; 39 }; 40 41 config = mkIf cfg.enable { 42 #!!! TODO: Use ExecReload (see https://github.com/NixOS/nixpkgs/issues/1988) 43 systemd.services.ngircd = { 44 description = "The ngircd IRC server"; 45 46 wantedBy = [ "multi-user.target" ]; 47 48 serviceConfig.ExecStart = "${cfg.package}/sbin/ngircd --config ${configFile} --nodaemon"; 49 50 serviceConfig.User = "ngircd"; 51 }; 52 53 users.extraUsers.ngircd = { 54 uid = config.ids.uids.ngircd; 55 description = "ngircd user."; 56 }; 57 }; 58}