1 { config, lib, pkgs, ... }:
4 cfg = config.services.shorewall6;
7 services.shorewall6 = {
8 enable = lib.mkOption {
12 Whether to enable Shorewall IPv6 Firewall.
15 Enabling this service WILL disable the existing NixOS
16 firewall! Default firewall rules provided by packages are not
17 considered at the moment.
21 package = lib.mkOption {
23 default = pkgs.shorewall;
24 defaultText = lib.literalExpression "pkgs.shorewall";
25 description = "The shorewall package to use.";
27 configs = lib.mkOption {
28 type = types.attrsOf types.lines;
31 This option defines the Shorewall configs.
32 The attribute name defines the name of the config,
33 and the attribute value defines the content of the config.
35 apply = lib.mapAttrs (name: text: pkgs.writeText "${name}" text);
40 config = lib.mkIf cfg.enable {
41 systemd.services.firewall.enable = false;
42 systemd.services.shorewall6 = {
43 description = "Shorewall IPv6 Firewall";
44 after = [ "ipset.target" ];
45 before = [ "network-pre.target" ];
46 wants = [ "network-pre.target" ];
47 wantedBy = [ "multi-user.target" ];
48 reloadIfChanged = true;
49 restartTriggers = lib.attrValues cfg.configs;
52 RemainAfterExit = "yes";
53 ExecStart = "${cfg.package}/bin/shorewall6 start";
54 ExecReload = "${cfg.package}/bin/shorewall6 reload";
55 ExecStop = "${cfg.package}/bin/shorewall6 stop";
58 install -D -d -m 750 /var/lib/shorewall6
59 install -D -d -m 755 /var/lock/subsys
60 touch /var/log/shorewall6.log
61 chmod 750 /var/log/shorewall6.log
65 etc = lib.mapAttrs' (name: conf: lib.nameValuePair "shorewall6/${name}" {source=conf;}) cfg.configs;
66 systemPackages = [ cfg.package ];