nbxplorer: use postgresql

The former DBTrie backend has been deprecated.
This commit is contained in:
Erik Arvstedt 2022-04-30 15:35:46 +02:00 committed by Jonas Nick
parent 29d2ffc111
commit 7de56b019f
No known key found for this signature in database
GPG Key ID: 4861DBF262123605
4 changed files with 29 additions and 8 deletions

View File

@ -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";
}

View File

@ -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"
);
};
}

View File

@ -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'

View File

@ -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: {