From 78e6d0143dd672d8d1645c648da058461572e3e1 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 19 Mar 2014 22:04:35 -0400 Subject: Add ngircd module --- nixos/modules/misc/ids.nix | 1 + nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/ngircd.nix | 58 ++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 nixos/modules/services/networking/ngircd.nix (limited to 'nixos/modules') diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 970b9caa2f9d..07ec5c8c2c4e 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -120,6 +120,7 @@ jenkins = 109; systemd-journal-gateway = 110; notbit = 111; + ngircd = 112; # When adding a uid, make sure it doesn't match an existing gid. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 1c2fca1f88b5..706f3da60b33 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -180,6 +180,7 @@ ./services/networking/minidlna.nix ./services/networking/nat.nix ./services/networking/networkmanager.nix + ./services/networking/ngircd.nix ./services/networking/notbit.nix ./services/networking/ntopng.nix ./services/networking/ntpd.nix diff --git a/nixos/modules/services/networking/ngircd.nix b/nixos/modules/services/networking/ngircd.nix new file mode 100644 index 000000000000..49e5f3559803 --- /dev/null +++ b/nixos/modules/services/networking/ngircd.nix @@ -0,0 +1,58 @@ +{ 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 "the ngircd IRC server"; + + config = mkOption { + description = "The ngircd configuration (see ngircd.conf(5))."; + + type = types.lines; + }; + + package = mkOption { + description = "The ngircd package."; + + type = types.package; + + default = 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.extraUsers.ngircd = { + uid = config.ids.uids.ngircd; + description = "ngircd user."; + }; + }; +} -- cgit 1.4.1