mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 18:23:09 +00:00
0a37316d6c
This commit replaces a lot of usages of `mkOption` with the package type, to be `mkPackageOption`, in order to reduce the amount of code.
56 lines
1.2 KiB
Nix
56 lines
1.2 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.ngircd;
|
|
|
|
configFile = pkgs.stdenv.mkDerivation {
|
|
name = "ngircd.conf";
|
|
|
|
text = cfg.config;
|
|
|
|
preferLocalBuild = true;
|
|
|
|
buildCommand = ''
|
|
echo -n "$text" > $out
|
|
${cfg.package}/sbin/ngircd --config $out --configtest
|
|
'';
|
|
};
|
|
in {
|
|
options = {
|
|
services.ngircd = {
|
|
enable = mkEnableOption (lib.mdDoc "the ngircd IRC server");
|
|
|
|
config = mkOption {
|
|
description = lib.mdDoc "The ngircd configuration (see ngircd.conf(5)).";
|
|
|
|
type = types.lines;
|
|
};
|
|
|
|
package = mkPackageOption pkgs "ngircd" { };
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
#!!! TODO: Use ExecReload (see https://github.com/NixOS/nixpkgs/issues/1988)
|
|
systemd.services.ngircd = {
|
|
description = "The ngircd IRC server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig.ExecStart = "${cfg.package}/sbin/ngircd --config ${configFile} --nodaemon";
|
|
|
|
serviceConfig.User = "ngircd";
|
|
};
|
|
|
|
users.users.ngircd = {
|
|
isSystemUser = true;
|
|
group = "ngircd";
|
|
description = "ngircd user.";
|
|
};
|
|
users.groups.ngircd = {};
|
|
|
|
};
|
|
}
|