liminix

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

client.nix (851B)


      1 {
      2   liminix,
      3   odhcp6c,
      4   odhcp-script,
      5   svc,
      6 }:
      7 { interface }:
      8 let
      9   inherit (liminix.services) longrun;
     10   inherit (liminix) outputRef;
     11   name = "dhcp6c.${interface.name}";
     12   autoconf = svc.ipv6.autoconfig.build {
     13     inherit interface;
     14   };
     15   service = longrun {
     16     inherit name;
     17     notification-fd = 10;
     18     run = ''
     19       export SERVICE_STATE=$SERVICE_OUTPUTS/${name}
     20       ifname=$(output ${interface} ifname)
     21       test -n "$ifname" && ${odhcp6c}/bin/odhcp6c -s ${odhcp-script} -e -v -p /run/${name}.pid -P0 $ifname
     22       )
     23     '';
     24     dependencies = [
     25       interface
     26       autoconf
     27     ];
     28   };
     29 in
     30 svc.secrets.subscriber.build {
     31   # if the ppp service gets restarted, the interface may be different and
     32   # we will have to restart dhcp on the new one
     33   watch = [ (outputRef interface "ifindex") ];
     34   action = "restart";
     35   inherit service;
     36 }