citadel

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

default.nix (3089B)


      1 extra:
      2 { config, lib, pkgs, ... }:
      3 
      4 let
      5   jb55pkgs = import <jb55pkgs> { inherit pkgs; };
      6 
      7   nostril = jb55pkgs.nostril;
      8 
      9   nix-bitcoin = import (pkgs.fetchFromGitHub {
     10     owner  = "fort-nix";
     11     repo   = "nix-bitcoin";
     12     rev    = "v0.0.89";
     13     sha256 = "sha256-SMJW+QZt3iRuoezjE12sopBsdLHDihXe/RerLfRpqoI=";
     14   }) { inherit pkgs; };
     15 
     16   plugins = ["summary"];
     17 
     18   mkPluginCfg = name:
     19     "plugin=${builtins.getAttr name (nix-bitcoin.clightning-plugins)}/${name}.py";
     20 
     21   bitcoinDataDir = "/zbig/bitcoin";
     22 
     23   base-bitcoin-conf = extra.private.bitcoin;
     24 
     25   bcli = "${pkgs.bitcoind}/bin/bitcoin-cli --datadir=${bitcoinDataDir} --conf=${base-bitcoin-conf-file} --rpcuser=${extra.private.btc-user} --rpcpassword=${extra.private.btc-pass}";
     26 
     27   bitcoin-conf = ''
     28     ${base-bitcoin-conf}
     29     walletnotify=${walletemail} %s %w
     30   '';
     31 
     32   base-bitcoin-conf-file = pkgs.writeText "bitcoin-base.conf" base-bitcoin-conf;
     33   bitcoin-conf-file = pkgs.writeText "bitcoin.conf" bitcoin-conf;
     34 
     35   dca = import ./dca.nix {
     36     inherit pkgs bcli;
     37     to = "jb55 ${extra.private.btc-supplier}";
     38     addr = extra.private.btc-supplier-addr;
     39   };
     40 
     41   walletemail = import ./walletemail.nix { inherit pkgs bcli nostril; inherit (extra) private; };
     42 
     43   spark-module = import ./modules/spark-wallet.nix nix-bitcoin.spark-wallet;
     44   spark-port = 9962;
     45 in
     46 {
     47   imports = [ spark-module ];
     48 
     49   services.spark-wallet.enable = false;
     50   services.spark-wallet.address = extra.machine.ztip;
     51   services.spark-wallet.port = spark-port;
     52   services.spark-wallet.publicUrl = "http://wallet.jb55.com";
     53 
     54   services.nginx.httpConfig = ''
     55     server {
     56       listen 80;
     57       listen 10.100.0.1:80;
     58       listen 192.168.87.26:80;
     59 
     60       server_name wallet.jb55.com;
     61 
     62       location /core/ {
     63         alias /var/www/lnlink-core/;
     64       }
     65 
     66       location /cln/ {
     67         alias /var/www/btcmerchant/;
     68       }
     69 
     70       location / {
     71         proxy_pass  http://127.0.0.1:9962;
     72 
     73         proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
     74         proxy_redirect off;
     75         proxy_buffering off;
     76         proxy_set_header        Host            $host;
     77         proxy_set_header        X-Real-IP       $remote_addr;
     78         proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
     79       }
     80     }
     81 
     82   '';
     83 
     84   services.bitcoind = {
     85     mainnet = {
     86       enable = if extra.is-minimal then false else true;
     87       dataDir = bitcoinDataDir;
     88       configFile = bitcoin-conf-file;
     89       user = "jb55";
     90       group = "users";
     91     };
     92   };
     93 
     94   #services.clightning.networks = {
     95   #  mainnet = {
     96   #    dataDir = "/home/jb55/.lightning-bitcoin";
     97 
     98   #    config = ''
     99   #      bitcoin-rpcuser=rpcuser
    100   #      bitcoin-rpcpassword=rpcpass
    101   #      bitcoin-rpcconnect=127.0.0.1
    102   #      bitcoin-rpcport=8332
    103   #      fee-per-satoshi=900
    104   #      bind-addr=0.0.0.0:9735
    105   #      announce-addr=24.84.152.187:9735
    106   #      network=bitcoin
    107   #      alias=jb55.com
    108   #      rgb=ff0000
    109   #      proxy=127.0.0.1:9050
    110   #      experimental-offers
    111   #      ${lib.concatStringsSep "\n" (map mkPluginCfg plugins)}
    112   #    '';
    113   #  };
    114   #};
    115 }