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.
22 package = lib.mkOption {
24 default = pkgs.shorewall;
25 defaultText = "pkgs.shorewall";
26 description = "The shorewall package to use.";
28 configs = lib.mkOption {
29 type = types.attrsOf types.str;
32 This option defines the Shorewall configs.
33 The attribute name defines the name of the config,
34 and the attribute value defines the content of the config.
36 apply = lib.mapAttrs (name: text: pkgs.writeText "${name}" text);
41 config = lib.mkIf cfg.enable {
42 systemd.services.firewall.enable = false;
43 systemd.services.shorewall6 = {
44 description = "Shorewall IPv6 Firewall";
45 after = [ "ipset.target" ];
46 before = [ "network-pre.target" ];
47 wants = [ "network-pre.target" ];
48 wantedBy = [ "multi-user.target" ];
49 reloadIfChanged = true;
50 restartTriggers = lib.attrValues cfg.configs;
53 RemainAfterExit = "yes";
54 ExecStart = "${cfg.package}/bin/shorewall6 start";
55 ExecReload = "${cfg.package}/bin/shorewall6 reload";
56 ExecStop = "${cfg.package}/bin/shorewall6 stop";
59 install -D -d -m 750 /var/lib/shorewall6
60 install -D -d -m 755 /var/lock/subsys
61 touch /var/log/shorewall6.log
62 chown 750 /var/log/shorewall6.log
66 etc = lib.mapAttrsToList
69 target = "shorewall6/${name}";
72 systemPackages = [ cfg.package ];