liminix

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

service.nix (835B)


      1 {
      2   liminix,
      3   lib,
      4   s6-rc-round-robin,
      5 }:
      6 { services, name }:
      7 let
      8   inherit (liminix.services) oneshot longrun;
      9   controlled-services = builtins.map (
     10     s:
     11     s.overrideAttrs (o: {
     12       inherit controller;
     13     })
     14   ) services;
     15   controller =
     16     let
     17       name' = "control-${name}";
     18     in
     19     longrun {
     20       name = name';
     21       run = ''
     22         in_outputs ${name'}
     23         exec ${s6-rc-round-robin}/bin/s6-rc-round-robin \
     24            -p ${proxy.name} \
     25            ${lib.concatStringsSep " " (builtins.map (f: f.name) controlled-services)}
     26       '';
     27     };
     28   proxy = oneshot rec {
     29     inherit name;
     30     inherit controller;
     31     buildInputs = controlled-services;
     32     up = ''
     33       echo start proxy ${name}
     34       set -x
     35       (in_outputs ${name}
     36        cp -rv $(output_path ${controller} active)/* .
     37       )
     38     '';
     39   };
     40 in
     41 proxy