mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
commit
bc8d08a511
@ -312,6 +312,7 @@
|
||||
./services/networking/lambdabot.nix
|
||||
./services/networking/mailpile.nix
|
||||
./services/networking/minidlna.nix
|
||||
./services/networking/miniupnpd.nix
|
||||
./services/networking/mstpd.nix
|
||||
./services/networking/murmur.nix
|
||||
./services/networking/namecoind.nix
|
||||
|
70
nixos/modules/services/networking/miniupnpd.nix
Normal file
70
nixos/modules/services/networking/miniupnpd.nix
Normal file
@ -0,0 +1,70 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.miniupnpd;
|
||||
configFile = pkgs.writeText "miniupnpd.conf" ''
|
||||
ext_ifname=${cfg.externalInterface}
|
||||
enable_natpmp=${if cfg.natpmp then "yes" else "no"}
|
||||
enable_upnp=${if cfg.upnp then "yes" else "no"}
|
||||
|
||||
${concatMapStrings (range: ''
|
||||
listening_ip=${range}
|
||||
'') cfg.internalIPs}
|
||||
|
||||
${cfg.appendConfig}
|
||||
'';
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.miniupnpd = {
|
||||
enable = mkEnableOption "MiniUPnP daemon";
|
||||
|
||||
externalInterface = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Name of the external interface.
|
||||
'';
|
||||
};
|
||||
|
||||
internalIPs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
example = [ "192.168.1.0/24" ];
|
||||
description = ''
|
||||
The IP address ranges to listen on.
|
||||
'';
|
||||
};
|
||||
|
||||
natpmp = mkEnableOption "NAT-PMP support";
|
||||
|
||||
upnp = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to enable UPNP support.
|
||||
'';
|
||||
};
|
||||
|
||||
appendConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Configuration lines appended to the MiniUPnP config.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.miniupnpd = {
|
||||
description = "MiniUPnP daemon";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.miniupnpd ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.miniupnpd}/bin/miniupnpd -d -f ${configFile}";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user