liminix

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

outboard.nix (956B)


      1 {
      2   liminix,
      3   lib,
      4   json-to-fstree,
      5   serviceFns,
      6 }:
      7 {
      8   name,
      9   url,
     10   interval,
     11   username,
     12   password,
     13   tlsCaCertificate,
     14   tlsCertificate,
     15   tlsPrivateKey,
     16 }:
     17 let
     18   inherit (liminix.services) longrun;
     19   inherit (lib) optionalString;
     20 in
     21 longrun {
     22   inherit name;
     23   buildInputs = [ json-to-fstree ];
     24   run = ''
     25     ${optionalString (username != null) ''
     26       export NETRC=$(mkstate ${name})/netrc
     27       (echo default ; echo login ${username} ; echo password ${password} ) > $NETRC
     28     ''}
     29     ${optionalString (tlsCertificate != null) ''
     30       export SSL_CLIENT_CERT_FILE=${tlsCertificate}
     31       export SSL_CLIENT_KEY_FILE=${tlsPrivateKey}
     32     ''}
     33     ${optionalString (tlsCaCertificate != null) ''
     34       export SSL_CA_CERT_FILE=${tlsCaCertificate}
     35     ''}
     36     ( in_outputs ${name}
     37       while : ; do
     38         ${json-to-fstree}/bin/json-to-fstree ${url} ${placeholder "out"}
     39         sleep ${builtins.toString (interval * 60)}
     40       done
     41     )
     42   '';
     43 }