at 24.11-pre 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 = mkPackageOption pkgs "ngircd" { }; 32 }; 33 }; 34 35 config = mkIf cfg.enable { 36 #!!! TODO: Use ExecReload (see https://github.com/NixOS/nixpkgs/issues/1988) 37 systemd.services.ngircd = { 38 description = "The ngircd IRC server"; 39 40 wantedBy = [ "multi-user.target" ]; 41 42 serviceConfig.ExecStart = "${cfg.package}/sbin/ngircd --config ${configFile} --nodaemon"; 43 44 serviceConfig.User = "ngircd"; 45 }; 46 47 users.users.ngircd = { 48 isSystemUser = true; 49 group = "ngircd"; 50 description = "ngircd user."; 51 }; 52 users.groups.ngircd = {}; 53 54 }; 55}