summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/iptables.nix15
1 files changed, 11 insertions, 4 deletions
diff --git a/modules/iptables.nix b/modules/iptables.nix
index 04fa4e7b..f2a719bb 100644
--- a/modules/iptables.nix
+++ b/modules/iptables.nix
@@ -1,4 +1,4 @@
-{ config, lib, pkgs, ... }: let {
+{ buildSystem, config, lib, pkgs, ... }: let {
cfg = config.tv.iptables;
body = {
@@ -264,6 +264,13 @@
tv-iptables-ipv6 = rule "6" "ip6tables";
};
+ # The translation is text, so the system that builds can make it with its
+ # own iptables. Emulated, the tool crashes for lack of netlink.
+ buildPkgs =
+ if buildSystem == pkgs.stdenv.hostPlatform.system
+ then pkgs
+ else import pkgs.path { system = buildSystem; };
+
translate = tool: nfproto: table: chain: rules: let
input = pkgs.writeText "tv-iptables-${tool}-${table}-${chain}" ''
*${table}
@@ -274,15 +281,15 @@
${lib.concatMapStrings (rule: "-A ${chain} ${rule}\n") rules}
COMMIT
'';
- output = pkgs.runCommand "tv-iptables-${tool}-${table}-${chain}.nft" {
- nativeBuildInputs = [ pkgs.iptables ];
+ output = buildPkgs.runCommand "tv-iptables-${tool}-${table}-${chain}.nft" {
+ nativeBuildInputs = [ buildPkgs.iptables ];
# Service names like "smtp" and host names like "leg.r" need the
# host's /etc/services and /etc/hosts.
NIX_REDIRECTS = lib.concatStringsSep ":" [
"/etc/hosts=${config.environment.etc.hosts.source}"
"/etc/services=${config.environment.etc.services.source}"
];
- LD_PRELOAD = "${pkgs.libredirect}/lib/libredirect.so";
+ LD_PRELOAD = "${buildPkgs.libredirect}/lib/libredirect.so";
} ''
${tool}-restore-translate -f ${input} > translated
sed -n 's/^add rule [a-z0-9]* ${table} ${chain} \(.*\)/\1/p' translated |