liminix

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

autoconfig.nix (651B)


      1 {
      2   liminix,
      3   writeAshScript,
      4   serviceFns,
      5   lib,
      6 }:
      7 {
      8   interface,
      9   role,
     10   sysctl,
     11 }:
     12 let
     13   inherit (liminix.services) oneshot;
     14   inherit (lib) recursiveUpdate;
     15   name = "${interface.name}.autoconfig";
     16   sysctls =
     17     let
     18       s = recursiveUpdate {
     19         autoconf = "1";
     20         accept_ra = (role == "host");
     21       } sysctl;
     22     in
     23     liminix.writeSysctls s;
     24 in
     25 oneshot {
     26   inherit name;
     27   dependencies = [ interface ];
     28   up = ''
     29     cd /proc/sys/net/ipv6/conf/$(output ${interface} ifname)
     30     ${sysctls}
     31   '';
     32   down = ''
     33     cd /proc/sys/net/ipv6/conf/$(output ${interface} ifname)
     34     echo "0" > autoconf
     35     echo "0" > accept_ra
     36   '';
     37 }