liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

forward.nix (442B)


      1 {
      2   liminix,
      3   lib,
      4 }:
      5 { enableIPv4, enableIPv6 }:
      6 let
      7   inherit (liminix.services) oneshot;
      8   ip4 = "/proc/sys/net/ipv4/conf/all/forwarding";
      9   ip6 = "/proc/sys/net/ipv6/conf/all/forwarding";
     10   opt = lib.optionalString;
     11   sysctls = b: "" + opt enableIPv4 "echo ${b} > ${ip4}\n" + opt enableIPv6 "echo ${b} > ${ip6}\n";
     12 in
     13 oneshot {
     14   name = "forwarding${opt enableIPv4 "4"}${opt enableIPv6 "6"}";
     15   up = sysctls "1";
     16   down = sysctls "0";
     17 }