git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #11548 from jgillich/upnpd

miniupnpd: add service

commitbc8d08a511617587d93fdac4f04f9b6195b3ad69 authorArseniy Seroka <jagajaga@users.noreply.github.com> dateThu 10 Dec 2015, 23:32 (11 years ago) parenta60895a29871ee
2 files changed+71
nixos/modules/module-list.nix+1 nixos/modules/services/networking/miniupnpd.nix+70
nixos/modules/module-list.nix+1
@@ -312,6 +312,7 @@
312312 ./services/networking/lambdabot.nix
313313 ./services/networking/mailpile.nix
314314 ./services/networking/minidlna.nix
315+ ./services/networking/miniupnpd.nix
315316 ./services/networking/mstpd.nix
316317 ./services/networking/murmur.nix
317318 ./services/networking/namecoind.nix
nixos/modules/services/networking/miniupnpd.nixnew file+70
@@ -0,0 +1,70 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.miniupnpd;
7+ configFile = pkgs.writeText "miniupnpd.conf" ''
8+ ext_ifname=${cfg.externalInterface}
9+ enable_natpmp=${if cfg.natpmp then "yes" else "no"}
10+ enable_upnp=${if cfg.upnp then "yes" else "no"}
11+
12+ ${concatMapStrings (range: ''
13+ listening_ip=${range}
14+ '') cfg.internalIPs}
15+
16+ ${cfg.appendConfig}
17+ '';
18+in
19+{
20+ options = {
21+ services.miniupnpd = {
22+ enable = mkEnableOption "MiniUPnP daemon";
23+
24+ externalInterface = mkOption {
25+ type = types.str;
26+ description = ''
27+ Name of the external interface.
28+ '';
29+ };
30+
31+ internalIPs = mkOption {
32+ type = types.listOf types.str;
33+ example = [ "192.168.1.0/24" ];
34+ description = ''
35+ The IP address ranges to listen on.
36+ '';
37+ };
38+
39+ natpmp = mkEnableOption "NAT-PMP support";
40+
41+ upnp = mkOption {
42+ default = true;
43+ type = types.bool;
44+ description = ''
45+ Whether to enable UPNP support.
46+ '';
47+ };
48+
49+ appendConfig = mkOption {
50+ type = types.lines;
51+ default = "";
52+ description = ''
53+ Configuration lines appended to the MiniUPnP config.
54+ '';
55+ };
56+ };
57+ };
58+
59+ config = mkIf cfg.enable {
60+ systemd.services.miniupnpd = {
61+ description = "MiniUPnP daemon";
62+ after = [ "network.target" ];
63+ wantedBy = [ "multi-user.target" ];
64+ path = [ pkgs.miniupnpd ];
65+ serviceConfig = {
66+ ExecStart = "${pkgs.miniupnpd}/bin/miniupnpd -d -f ${configFile}";
67+ };
68+ };
69+ };
70+}