From 7de56b019fe34872dbfb77a46ba5fadd15e1dc2d Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sat, 30 Apr 2022 15:35:46 +0200 Subject: [PATCH] nbxplorer: use postgresql The former DBTrie backend has been deprecated. --- examples/configuration.nix | 2 +- modules/backups.nix | 4 +++- modules/btcpayserver.nix | 20 ++++++++++++++------ modules/versioning.nix | 11 +++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/examples/configuration.nix b/examples/configuration.nix index 84d0c0e..93b9f14 100644 --- a/examples/configuration.nix +++ b/examples/configuration.nix @@ -268,5 +268,5 @@ # The nix-bitcoin release version that your config is compatible with. # When upgrading to a backwards-incompatible release, nix-bitcoin will display an # an error and provide hints for migrating your config to the new release. - nix-bitcoin.configVersion = "0.0.65"; + nix-bitcoin.configVersion = "0.0.70"; } diff --git a/modules/backups.nix b/modules/backups.nix index 9f2220a..21e0b20 100644 --- a/modules/backups.nix +++ b/modules/backups.nix @@ -121,6 +121,8 @@ in { fi ''; - services.backups.postgresqlDatabases = mkIf config.services.btcpayserver.enable [ "btcpaydb" ]; + services.backups.postgresqlDatabases = mkIf config.services.btcpayserver.enable ( + [ "btcpaydb" ] ++ optional cfg.with-bulk-data "nbxplorer" + ); }; } diff --git a/modules/btcpayserver.nix b/modules/btcpayserver.nix index 2b55e5b..8f5f92a 100644 --- a/modules/btcpayserver.nix +++ b/modules/btcpayserver.nix @@ -136,11 +136,17 @@ in { }; services.postgresql = { enable = true; - ensureDatabases = [ "btcpaydb" ]; - ensureUsers = [{ - name = cfg.btcpayserver.user; - ensurePermissions."DATABASE btcpaydb" = "ALL PRIVILEGES"; - }]; + ensureDatabases = [ "btcpaydb" "nbxplorer" ]; + ensureUsers = [ + { + name = cfg.btcpayserver.user; + ensurePermissions."DATABASE btcpaydb" = "ALL PRIVILEGES"; + } + { + name = cfg.nbxplorer.user; + ensurePermissions."DATABASE nbxplorer" = "ALL PRIVILEGES"; + } + ]; }; systemd.tmpfiles.rules = [ @@ -162,10 +168,12 @@ in { lbtcrpcurl=http://${nbLib.addressWithPort liquidd.rpc.address liquidd.rpc.port} lbtcnodeendpoint=${nbLib.addressWithPort liquidd.address liquidd.whitelistedPort} ''} + postgres=User ID=${cfg.nbxplorer.user};Host=/run/postgresql;Database=nbxplorer + automigrate=1 ''; in rec { wantedBy = [ "multi-user.target" ]; - requires = [ "bitcoind.service" ] ++ optional cfg.btcpayserver.lbtc "liquidd.service"; + requires = [ "bitcoind.service" "postgresql.service" ] ++ optional cfg.btcpayserver.lbtc "liquidd.service"; after = requires; preStart = '' install -m 600 ${configFile} '${cfg.nbxplorer.dataDir}/settings.config' diff --git a/modules/versioning.nix b/modules/versioning.nix index e1d6761..aa9693f 100644 --- a/modules/versioning.nix +++ b/modules/versioning.nix @@ -202,6 +202,17 @@ let config to your node. ''; } + { + version = "0.0.70"; + condition = config.services.nbxplorer.enable; + message = '' + The nbxplorer database backend has changed from DBTrie to Postgresql. + The new `services.postgresql` database name is `nbxplorer`. + The migration happens automatically after deploying. + Migration time for a large server with a 5GB DBTrie database takes about 40 minutes. + See also: https://github.com/dgarage/NBXplorer/blob/master/docs/Postgres-Migration.md + ''; + } ]; mkOnionServiceChange = service: {