2024-10-04 17:53:32 +01:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
bitcoin-rpcpassword-privileged = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."software/bitcoind/bitcoin-rpcpassword-privileged".path;
|
|
|
|
bitcoin-rpcpassword-public = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."software/bitcoind/bitcoin-rpcpassword-public".path;
|
|
|
|
bitcoin-HMAC-privileged = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."software/bitcoind/bitcoin-HMAC-privileged".path;
|
|
|
|
bitcoin-HMAC-public = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."software/bitcoind/bitcoin-HMAC-public".path;
|
|
|
|
pubKeys = lib.filesystem.listFilesRecursive ../users/keys;
|
|
|
|
in {
|
|
|
|
sops.secrets = {
|
|
|
|
"software/bitcoind/bitcoin-rpcpassword-privileged" = {};
|
|
|
|
"software/bitcoind/bitcoin-rpcpassword-public" = {};
|
|
|
|
"software/bitcoind/bitcoin-HMAC-privileged" = {};
|
|
|
|
"software/bitcoind/bitcoin-HMAC-public" = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.nat.enable = true;
|
|
|
|
networking.nat.internalInterfaces = ["ve-+"];
|
2024-10-05 16:42:16 +01:00
|
|
|
networking.nat.externalInterface = "br0";
|
|
|
|
# networking.firewall.enable = true;
|
|
|
|
# networking.firewall.allowedTCPPorts = [80 443 22];
|
|
|
|
# networking.firewall.trustedInterfaces = ["ve-btcnode"];
|
2024-10-04 17:53:32 +01:00
|
|
|
|
|
|
|
containers.bitcoin-node = {
|
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
2024-10-05 16:42:16 +01:00
|
|
|
hostBridge = "br0";
|
2024-10-04 17:53:32 +01:00
|
|
|
nixpkgs = pkgs.path;
|
|
|
|
bindMounts = {
|
|
|
|
"/etc/nix-bitcoin-secrets/bitcoin-rpcpassword-privileged" = {
|
|
|
|
hostPath = "${bitcoin-rpcpassword-privileged}";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
"/etc/nix-bitcoin-secrets/bitcoin-rpcpassword-public" = {
|
|
|
|
hostPath = "${bitcoin-rpcpassword-public}";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
"/etc/nix-bitcoin-secrets/bitcoin-HMAC-privileged" = {
|
|
|
|
hostPath = "${bitcoin-HMAC-privileged}";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
"/etc/nix-bitcoin-secrets/bitcoin-HMAC-public" = {
|
|
|
|
hostPath = "${bitcoin-HMAC-public}";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
2024-10-05 16:42:16 +01:00
|
|
|
"/var/lib/bitcoind" = {
|
|
|
|
hostPath = "/media/main-ssd/nix-bitcoin/bitcoind";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
"/var/lib/electrs" = {
|
|
|
|
hostPath = "/media/main-ssd/nix-bitcoin/electrs";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
"/var/lib/mysql" = {
|
|
|
|
hostPath = "/media/main-ssd/nix-bitcoin/mysql";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
"/var/lib/tor" = {
|
|
|
|
hostPath = "/media/main-ssd/nix-bitcoin/tor";
|
2024-10-04 17:53:32 +01:00
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-10-05 16:42:16 +01:00
|
|
|
# forwardPorts = [
|
|
|
|
# {
|
|
|
|
# containerPort = 50001;
|
|
|
|
# hostPort = 50001;
|
|
|
|
# protocol = "tcp";
|
|
|
|
# }
|
|
|
|
# ];
|
2024-10-04 17:53:32 +01:00
|
|
|
|
|
|
|
config = {
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
imports = [
|
|
|
|
inputs.nix-bitcoin.nixosModules.default
|
|
|
|
];
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
vim
|
|
|
|
lsof
|
|
|
|
jq
|
|
|
|
];
|
|
|
|
networking = {
|
2024-10-05 16:42:16 +01:00
|
|
|
defaultGateway = "10.0.10.1";
|
|
|
|
interfaces.eth0.ipv4.addresses = [ { "address" = "10.0.10.4"; "prefixLength" = 24; } ];
|
2024-10-04 17:53:32 +01:00
|
|
|
firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowedTCPPorts = [
|
|
|
|
80
|
|
|
|
443
|
|
|
|
22
|
|
|
|
config.containers.bitcoin-node.config.services.bitcoind.rpc.port
|
|
|
|
config.containers.bitcoin-node.config.services.mempool.frontend.port
|
2024-10-05 16:42:16 +01:00
|
|
|
config.containers.bitcoin-node.config.services.electrs.port
|
2024-10-04 17:53:32 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
useHostResolvConf = lib.mkForce false;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.resolved.enable = true;
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
settings.PasswordAuthentication = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
nix-bitcoin.generateSecrets = true;
|
|
|
|
|
|
|
|
users.users.root = {
|
|
|
|
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
|
|
|
|
};
|
|
|
|
|
|
|
|
# node services here
|
|
|
|
services = {
|
|
|
|
tor = {
|
|
|
|
enable = true;
|
|
|
|
client.enable = true;
|
|
|
|
};
|
|
|
|
bitcoind = {
|
|
|
|
tor.proxy = true;
|
|
|
|
tor.enforce = true;
|
|
|
|
enable = true;
|
2024-10-05 16:42:16 +01:00
|
|
|
dataDir = "/var/lib/bitcoind";
|
2024-10-04 17:53:32 +01:00
|
|
|
dbCache = 5000;
|
|
|
|
txindex = true;
|
|
|
|
rpc = {
|
|
|
|
address = "0.0.0.0";
|
|
|
|
threads = 6;
|
|
|
|
allowip = ["10.0.0.0/8"];
|
|
|
|
users = let
|
|
|
|
name = "bitcoin";
|
|
|
|
in {
|
|
|
|
privileged.name = name;
|
|
|
|
public.name = name;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
extraConfig = ''
|
|
|
|
onlynet=onion
|
|
|
|
bind=127.0.0.1
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
electrs = {
|
|
|
|
tor.enforce = true;
|
|
|
|
enable = true;
|
2024-10-05 16:42:16 +01:00
|
|
|
dataDir = "/var/lib/electrs";
|
|
|
|
address = "0.0.0.0";
|
2024-10-04 17:53:32 +01:00
|
|
|
};
|
|
|
|
mempool = {
|
|
|
|
enable = true;
|
|
|
|
electrumServer = "electrs";
|
|
|
|
frontend = {
|
|
|
|
port = 4080;
|
|
|
|
address = "0.0.0.0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
nix-bitcoin.onionServices = {
|
|
|
|
bitcoind.enable = true;
|
|
|
|
electrs.enable = true;
|
|
|
|
mempool-frontend.enable = true;
|
|
|
|
};
|
|
|
|
system.stateVersion = "24.05";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|