citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

spark-wallet.nix (1351B)


      1 spark-wallet:
      2 { config, lib, pkgs, ... }:
      3 
      4 with lib;
      5 
      6 let
      7   cfg = config.services.spark-wallet;
      8 
      9   startScript = ''
     10     exec ${spark-wallet}/bin/spark-wallet \
     11       --ln-path "/home/jb55/.lightning/bitcoin"  \
     12       --host ${cfg.address} --port ${toString cfg.port} \
     13       --public-url "http://wallet.jb55.com" \
     14       --pairing-qr --print-key ${cfg.extraArgs}
     15   '';
     16 in {
     17   options.services.spark-wallet = {
     18     enable = mkEnableOption "spark-wallet";
     19     address = mkOption {
     20       type = types.str;
     21       default = "localhost";
     22       description = "http(s) server address.";
     23     };
     24     port = mkOption {
     25       type = types.port;
     26       default = 9737;
     27       description = "http(s) server port.";
     28     };
     29     publicUrl = mkOption {
     30       type = types.str;
     31       default = "localhost";
     32       description = "public url";
     33     };
     34     extraArgs = mkOption {
     35       type = types.separatedString " ";
     36       default = "";
     37       description = "Extra command line arguments passed to spark-wallet.";
     38     };
     39   };
     40 
     41   config = mkIf cfg.enable {
     42     systemd.user.services.spark-wallet = {
     43       wantedBy = [ "multi-user.target" ];
     44       requires = [ "clightning-mainnet.service" ];
     45       after = [ "clightning-mainnet.service" ];
     46       script = startScript;
     47       serviceConfig = {
     48         Restart = "on-failure";
     49         RestartSec = "10s";
     50       };
     51     };
     52   };
     53 }