liminix

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

client.nix (780B)


      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   service =
     13     longrun {
     14       inherit name;
     15       notification-fd = 10;
     16       run = ''
     17         export SERVICE_STATE=$SERVICE_OUTPUTS/${name}
     18         ifname=$(output ${interface} ifname)
     19         test -n "$ifname" && ${odhcp6c}/bin/odhcp6c -s ${odhcp-script} -e -v -p /run/${name}.pid -P0 $ifname
     20         )
     21       '';
     22       dependencies = [ interface ];
     23     };
     24 in svc.secrets.subscriber.build {
     25   # if the ppp service gets restarted, the interface may be different and
     26   # we will have to restart dhcp on the new one
     27   watch = [ (outputRef interface "ifindex") ];
     28   action = "restart";
     29   inherit service;
     30 }