liminix

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

forward.nix (475B)


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