2022-08-27 07:15:06 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let cfg = config.services.clightning.plugins.trustedcoin; in
|
|
|
|
{
|
|
|
|
options.services.clightning.plugins.trustedcoin = {
|
|
|
|
enable = mkEnableOption "Trustedcoin (clightning plugin)";
|
2023-08-03 16:38:45 +03:00
|
|
|
|
2022-08-27 07:15:06 +03:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = config.nix-bitcoin.pkgs.trustedcoin;
|
|
|
|
defaultText = "config.nix-bitcoin.pkgs.trustedcoin";
|
2023-03-03 23:00:00 +03:00
|
|
|
description = mdDoc "The package providing trustedcoin binaries.";
|
2022-08-27 07:15:06 +03:00
|
|
|
};
|
2023-08-03 16:38:45 +03:00
|
|
|
|
|
|
|
tor.proxy = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = config.services.clightning.tor.proxy;
|
|
|
|
description = mdDoc "Whether to proxy outgoing connections with Tor.";
|
|
|
|
};
|
2022-08-27 07:15:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2023-08-03 01:05:03 +03:00
|
|
|
services.clightning = {
|
|
|
|
useBcliPlugin = false;
|
|
|
|
extraConfig = ''
|
|
|
|
plugin=${cfg.package}/bin/trustedcoin
|
|
|
|
'';
|
2023-08-03 16:38:45 +03:00
|
|
|
tor.enforce = mkIf (!cfg.tor.proxy) false;
|
2023-08-03 01:05:03 +03:00
|
|
|
};
|
2023-04-13 22:00:00 +03:00
|
|
|
|
2023-08-03 16:38:45 +03:00
|
|
|
systemd.services.clightning.environment = mkIf (cfg.tor.proxy) {
|
|
|
|
HTTPS_PROXY = let
|
|
|
|
clnProxy = config.services.clightning.proxy;
|
|
|
|
proxy = if clnProxy != null then clnProxy else config.nix-bitcoin.torClientAddressWithPort;
|
|
|
|
in
|
|
|
|
"socks5://${proxy}";
|
2023-04-13 22:00:00 +03:00
|
|
|
};
|
2022-08-27 07:15:06 +03:00
|
|
|
};
|
|
|
|
}
|