at 25.11-pre 1.2 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8with lib; 9 10let 11 cfg = config.services.ngircd; 12 13 configFile = pkgs.stdenv.mkDerivation { 14 name = "ngircd.conf"; 15 16 text = cfg.config; 17 18 preferLocalBuild = true; 19 20 buildCommand = '' 21 echo -n "$text" > $out 22 ${cfg.package}/sbin/ngircd --config $out --configtest 23 ''; 24 }; 25in 26{ 27 options = { 28 services.ngircd = { 29 enable = mkEnableOption "the ngircd IRC server"; 30 31 config = mkOption { 32 description = "The ngircd configuration (see {manpage}`ngircd.conf(5)`)."; 33 34 type = types.lines; 35 }; 36 37 package = mkPackageOption pkgs "ngircd" { }; 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.users.ngircd = { 54 isSystemUser = true; 55 group = "ngircd"; 56 description = "ngircd user."; 57 }; 58 users.groups.ngircd = { }; 59 60 }; 61}