liminix

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

service.nix (1052B)


      1 {
      2   liminix
      3 , hostapd
      4 , writeText
      5 , lib
      6 }:
      7 { interface, params} :
      8 let
      9   inherit (liminix.services) longrun;
     10   inherit (lib) concatStringsSep mapAttrsToList;
     11   inherit (liminix.lib) typeChecked;
     12   inherit (lib) mkOption types;
     13 
     14   # This is not a friendly interface to configuring a wireless AP: it
     15   # just passes everything straight through to the hostapd config.
     16   # When we've worked out what the sensible options are to expose,
     17   # we'll add them as top-level attributes and rename params to
     18   # extraParams
     19 
     20   name = "${interface.name}.hostapd";
     21   defaults =  {
     22     driver = "nl80211";
     23     logger_syslog = "-1";
     24     logger_syslog_level = 1;
     25     ctrl_interface = "/run/hostapd";
     26     ctrl_interface_group = 0;
     27   };
     28 
     29   conf = writeText "hostapd.conf"
     30     (concatStringsSep
     31       "\n"
     32       (mapAttrsToList
     33         (name: value: "${name}=${toString value}")
     34         (defaults // params)));
     35 in longrun {
     36   inherit name;
     37   dependencies = [ interface ];
     38   run = "${hostapd}/bin/hostapd -i $(output ${interface} ifname)  -P /run/${name}.pid -S ${conf}";
     39 }