1{
2 lib,
3 config,
4 options,
5 ...
6}:
7{
8 imports = [ (import ./common.nix "bank") ];
9
10 options.services.libeufin.bank = {
11 initialAccounts = lib.mkOption {
12 type = lib.types.listOf lib.types.attrs;
13 description = ''
14 Accounts to enable before the bank service starts.
15
16 This is mainly needed for the nexus currency conversion
17 since the exchange's bank account is expected to be already
18 registered.
19
20 Don't forget to change the account passwords afterwards.
21 '';
22 default = [ ];
23 };
24
25 settings = lib.mkOption {
26 description = ''
27 Configuration options for the libeufin bank system config file.
28
29 For a list of all possible options, please see the man page [`libeufin-bank.conf(5)`](https://docs.taler.net/manpages/libeufin-bank.conf.5.html)
30 '';
31 type = lib.types.submodule {
32 inherit (options.services.libeufin.settings.type.nestedTypes) freeformType;
33 options = {
34 libeufin-bank = {
35 CURRENCY = lib.mkOption {
36 type = lib.types.str;
37 description = ''
38 The currency under which the libeufin-bank should operate.
39
40 This defaults to the GNU taler module's currency for convenience
41 but if you run libeufin-bank separately from taler, you must set
42 this yourself.
43 '';
44 };
45 PORT = lib.mkOption {
46 type = lib.types.port;
47 default = 8082;
48 description = ''
49 The port on which libeufin-bank should listen.
50 '';
51 };
52 SUGGESTED_WITHDRAWAL_EXCHANGE = lib.mkOption {
53 type = lib.types.str;
54 default = "https://exchange.demo.taler.net/";
55 description = ''
56 Exchange that is suggested to wallets when withdrawing.
57
58 Note that, in order for withdrawals to work, your libeufin-bank
59 must be able to communicate with and send money etc. to the bank
60 at which the exchange used for withdrawals has its bank account.
61
62 If you also have your own bank and taler exchange network, you
63 probably want to set one of your exchange's url here instead of
64 the demo exchange.
65
66 This setting must always be set in order for the Android app to
67 not crash during the withdrawal process but the exchange to be
68 used can always be changed in the app.
69 '';
70 };
71 };
72 libeufin-bankdb-postgres = {
73 CONFIG = lib.mkOption {
74 type = lib.types.str;
75 description = ''
76 The database connection string for the libeufin-bank database.
77 '';
78 };
79 };
80 };
81 };
82 };
83 };
84
85 config = {
86 services.libeufin.bank.settings.libeufin-bank.CURRENCY = lib.mkIf (
87 config.services.taler.enable && (config.services.taler.settings.taler ? CURRENCY)
88 ) config.services.taler.settings.taler.CURRENCY;
89
90 services.libeufin.bank.settings.libeufin-bankdb-postgres.CONFIG =
91 lib.mkIf config.services.libeufin.bank.createLocalDatabase "postgresql:///libeufin-bank";
92 };
93}