nixpkgs/nixos/modules/services/finance/taler/common.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

129 lines
3.4 KiB
Nix
Raw Normal View History

nixos/taler: init module basic config set that makes the service at least start add secmod helpers and taler-global runtime dir support for includes taler denominations Only enable services if taler is enabled fix wirewatch service name use correct permissions for database schema The current permissions don't work or aren't enough and cause the wirewatch and closer services to fail. nixos/libeufin: init module libeufin: refactor module libeufin: add main service nixos/taler: configure settings using options Works, but can be refactored further taler: refactor settings options trim settings defaults to the absolutely necessary ones nixos/libeufin: refactor and move to separate dir nixos/libeufin: set defaultText nixos/libeufin: use getExe nixos/libeufin-bank: move to own dir nixos/libeufin: move libeufin related config into its own config file nixos/libeufin/bank: extract dbinitServiceName into var nixos/libeufin: move script to ExecStart nixos/libeufin: fix config file name nixos/taler: refactor config file nixos/taler-exchange: grant delete to taler-exchange-aggregator Would repeatedly attempt to delete in a table where it wasn't allowed to and cause insane spam in the postgres log. nixos/taler/exchange: move exchange-specific options to exchange nixos/taler: move generic taler settings into taler system module nixos/taler: import exchange in module-list.nix nixos/taler-exchange: refactor services group name nixos/taler-exchange: use taler-harness to generate coins The taler-wallet-cli does not have the deployment subcommand anymore, but the docs still say that it should be used to generate the keys. For now, the keys should be generated with taler-harness. nixos/taler-exchange: add option to enable accounts nixos/taler: add missing descriptions nixos/taler(exchange): add description & use getExe' nixos/taler(merchant): init submodule nixos/taler: use correct script for db access nixos/taler: merchant add depositcheck path nixos/taler: review suggestions nixos/taler: make runtimeDir into an option, refactor nixos/taler: init mkTalerModule nixos/taler: use mkTalerModule for exchange nixos/taler: exchange fixups nixos/taler: use mkTalerModule for merchant nixos/taler: improve how dbInit script is created nixos/taler: remove exchange enableAccounts option nixos/taler: explicitly specify psql user Sometimes the dbinit service fails to find the user. nixos/taler: add openFirewall option; install package feat: add assertions, remove throw feat(taler): use module system instead of functions Also: - remove throw from denominateConfig - rename `utils.nix` to `common.nix` feat(taler): refactor modules feat: move taler module to services/finance refactor(exchange): replace throw with assert refactor(exchange,merchant): settings options fix(taler): manpage URLs fix(exchange): public key assert refactor(taler): use configFile feat(taler): include component configs directly Makes services detect config changes better.
2024-06-27 18:47:14 +02:00
# TODO: create a common module generator for Taler and Libeufin?
{
talerComponent ? "",
servicesDB ? [ ],
servicesNoDB ? [ ],
...
}:
{
lib,
pkgs,
config,
...
}:
let
cfg = cfgTaler.${talerComponent};
cfgTaler = config.services.taler;
settingsFormat = pkgs.formats.ini { };
configFile = config.environment.etc."taler/taler.conf".source;
componentConfigFile = settingsFormat.generate "generated-taler-${talerComponent}.conf" cfg.settings;
services = servicesDB ++ servicesNoDB;
dbName = "taler-${talerComponent}-httpd";
groupName = "taler-${talerComponent}-services";
inherit (cfgTaler) runtimeDir;
in
{
options = {
services.taler.${talerComponent} = {
enable = lib.mkEnableOption "the GNU Taler ${talerComponent}";
package = lib.mkPackageOption pkgs "taler-${talerComponent}" { };
# TODO: make option accept multiple debugging levels?
debug = lib.mkEnableOption "debug logging";
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to open ports in the firewall";
};
};
};
config = lib.mkIf cfg.enable {
services.taler.enable = cfg.enable;
services.taler.includes = [ componentConfigFile ];
systemd.services = lib.mergeAttrsList [
# Main services
(lib.genAttrs (map (n: "taler-${talerComponent}-${n}") services) (name: {
serviceConfig = {
DynamicUser = true;
User = dbName;
nixos/taler: init module basic config set that makes the service at least start add secmod helpers and taler-global runtime dir support for includes taler denominations Only enable services if taler is enabled fix wirewatch service name use correct permissions for database schema The current permissions don't work or aren't enough and cause the wirewatch and closer services to fail. nixos/libeufin: init module libeufin: refactor module libeufin: add main service nixos/taler: configure settings using options Works, but can be refactored further taler: refactor settings options trim settings defaults to the absolutely necessary ones nixos/libeufin: refactor and move to separate dir nixos/libeufin: set defaultText nixos/libeufin: use getExe nixos/libeufin-bank: move to own dir nixos/libeufin: move libeufin related config into its own config file nixos/libeufin/bank: extract dbinitServiceName into var nixos/libeufin: move script to ExecStart nixos/libeufin: fix config file name nixos/taler: refactor config file nixos/taler-exchange: grant delete to taler-exchange-aggregator Would repeatedly attempt to delete in a table where it wasn't allowed to and cause insane spam in the postgres log. nixos/taler/exchange: move exchange-specific options to exchange nixos/taler: move generic taler settings into taler system module nixos/taler: import exchange in module-list.nix nixos/taler-exchange: refactor services group name nixos/taler-exchange: use taler-harness to generate coins The taler-wallet-cli does not have the deployment subcommand anymore, but the docs still say that it should be used to generate the keys. For now, the keys should be generated with taler-harness. nixos/taler-exchange: add option to enable accounts nixos/taler: add missing descriptions nixos/taler(exchange): add description & use getExe' nixos/taler(merchant): init submodule nixos/taler: use correct script for db access nixos/taler: merchant add depositcheck path nixos/taler: review suggestions nixos/taler: make runtimeDir into an option, refactor nixos/taler: init mkTalerModule nixos/taler: use mkTalerModule for exchange nixos/taler: exchange fixups nixos/taler: use mkTalerModule for merchant nixos/taler: improve how dbInit script is created nixos/taler: remove exchange enableAccounts option nixos/taler: explicitly specify psql user Sometimes the dbinit service fails to find the user. nixos/taler: add openFirewall option; install package feat: add assertions, remove throw feat(taler): use module system instead of functions Also: - remove throw from denominateConfig - rename `utils.nix` to `common.nix` feat(taler): refactor modules feat: move taler module to services/finance refactor(exchange): replace throw with assert refactor(exchange,merchant): settings options fix(taler): manpage URLs fix(exchange): public key assert refactor(taler): use configFile feat(taler): include component configs directly Makes services detect config changes better.
2024-06-27 18:47:14 +02:00
Group = groupName;
ExecStart = toString [
(lib.getExe' cfg.package name)
"-c ${configFile}"
(lib.optionalString cfg.debug " -L debug")
];
RuntimeDirectory = name;
StateDirectory = name;
CacheDirectory = name;
ReadWritePaths = [ runtimeDir ];
Restart = "always";
RestartSec = "10s";
};
requires = [ "taler-${talerComponent}-dbinit.service" ];
after = [ "taler-${talerComponent}-dbinit.service" ];
wantedBy = [ "multi-user.target" ]; # TODO slice?
documentation = [
"man:taler-${talerComponent}-${name}(1)"
"info:taler-${talerComponent}"
];
nixos/taler: init module basic config set that makes the service at least start add secmod helpers and taler-global runtime dir support for includes taler denominations Only enable services if taler is enabled fix wirewatch service name use correct permissions for database schema The current permissions don't work or aren't enough and cause the wirewatch and closer services to fail. nixos/libeufin: init module libeufin: refactor module libeufin: add main service nixos/taler: configure settings using options Works, but can be refactored further taler: refactor settings options trim settings defaults to the absolutely necessary ones nixos/libeufin: refactor and move to separate dir nixos/libeufin: set defaultText nixos/libeufin: use getExe nixos/libeufin-bank: move to own dir nixos/libeufin: move libeufin related config into its own config file nixos/libeufin/bank: extract dbinitServiceName into var nixos/libeufin: move script to ExecStart nixos/libeufin: fix config file name nixos/taler: refactor config file nixos/taler-exchange: grant delete to taler-exchange-aggregator Would repeatedly attempt to delete in a table where it wasn't allowed to and cause insane spam in the postgres log. nixos/taler/exchange: move exchange-specific options to exchange nixos/taler: move generic taler settings into taler system module nixos/taler: import exchange in module-list.nix nixos/taler-exchange: refactor services group name nixos/taler-exchange: use taler-harness to generate coins The taler-wallet-cli does not have the deployment subcommand anymore, but the docs still say that it should be used to generate the keys. For now, the keys should be generated with taler-harness. nixos/taler-exchange: add option to enable accounts nixos/taler: add missing descriptions nixos/taler(exchange): add description & use getExe' nixos/taler(merchant): init submodule nixos/taler: use correct script for db access nixos/taler: merchant add depositcheck path nixos/taler: review suggestions nixos/taler: make runtimeDir into an option, refactor nixos/taler: init mkTalerModule nixos/taler: use mkTalerModule for exchange nixos/taler: exchange fixups nixos/taler: use mkTalerModule for merchant nixos/taler: improve how dbInit script is created nixos/taler: remove exchange enableAccounts option nixos/taler: explicitly specify psql user Sometimes the dbinit service fails to find the user. nixos/taler: add openFirewall option; install package feat: add assertions, remove throw feat(taler): use module system instead of functions Also: - remove throw from denominateConfig - rename `utils.nix` to `common.nix` feat(taler): refactor modules feat: move taler module to services/finance refactor(exchange): replace throw with assert refactor(exchange,merchant): settings options fix(taler): manpage URLs fix(exchange): public key assert refactor(taler): use configFile feat(taler): include component configs directly Makes services detect config changes better.
2024-06-27 18:47:14 +02:00
}))
# Database Initialisation
{
"taler-${talerComponent}-dbinit" = {
path = [ config.services.postgresql.package ];
documentation = [
"man:taler-${talerComponent}-dbinit(1)"
"info:taler-${talerComponent}"
];
nixos/taler: init module basic config set that makes the service at least start add secmod helpers and taler-global runtime dir support for includes taler denominations Only enable services if taler is enabled fix wirewatch service name use correct permissions for database schema The current permissions don't work or aren't enough and cause the wirewatch and closer services to fail. nixos/libeufin: init module libeufin: refactor module libeufin: add main service nixos/taler: configure settings using options Works, but can be refactored further taler: refactor settings options trim settings defaults to the absolutely necessary ones nixos/libeufin: refactor and move to separate dir nixos/libeufin: set defaultText nixos/libeufin: use getExe nixos/libeufin-bank: move to own dir nixos/libeufin: move libeufin related config into its own config file nixos/libeufin/bank: extract dbinitServiceName into var nixos/libeufin: move script to ExecStart nixos/libeufin: fix config file name nixos/taler: refactor config file nixos/taler-exchange: grant delete to taler-exchange-aggregator Would repeatedly attempt to delete in a table where it wasn't allowed to and cause insane spam in the postgres log. nixos/taler/exchange: move exchange-specific options to exchange nixos/taler: move generic taler settings into taler system module nixos/taler: import exchange in module-list.nix nixos/taler-exchange: refactor services group name nixos/taler-exchange: use taler-harness to generate coins The taler-wallet-cli does not have the deployment subcommand anymore, but the docs still say that it should be used to generate the keys. For now, the keys should be generated with taler-harness. nixos/taler-exchange: add option to enable accounts nixos/taler: add missing descriptions nixos/taler(exchange): add description & use getExe' nixos/taler(merchant): init submodule nixos/taler: use correct script for db access nixos/taler: merchant add depositcheck path nixos/taler: review suggestions nixos/taler: make runtimeDir into an option, refactor nixos/taler: init mkTalerModule nixos/taler: use mkTalerModule for exchange nixos/taler: exchange fixups nixos/taler: use mkTalerModule for merchant nixos/taler: improve how dbInit script is created nixos/taler: remove exchange enableAccounts option nixos/taler: explicitly specify psql user Sometimes the dbinit service fails to find the user. nixos/taler: add openFirewall option; install package feat: add assertions, remove throw feat(taler): use module system instead of functions Also: - remove throw from denominateConfig - rename `utils.nix` to `common.nix` feat(taler): refactor modules feat: move taler module to services/finance refactor(exchange): replace throw with assert refactor(exchange,merchant): settings options fix(taler): manpage URLs fix(exchange): public key assert refactor(taler): use configFile feat(taler): include component configs directly Makes services detect config changes better.
2024-06-27 18:47:14 +02:00
serviceConfig = {
Type = "oneshot";
DynamicUser = true;
User = dbName;
Group = groupName;
nixos/taler: init module basic config set that makes the service at least start add secmod helpers and taler-global runtime dir support for includes taler denominations Only enable services if taler is enabled fix wirewatch service name use correct permissions for database schema The current permissions don't work or aren't enough and cause the wirewatch and closer services to fail. nixos/libeufin: init module libeufin: refactor module libeufin: add main service nixos/taler: configure settings using options Works, but can be refactored further taler: refactor settings options trim settings defaults to the absolutely necessary ones nixos/libeufin: refactor and move to separate dir nixos/libeufin: set defaultText nixos/libeufin: use getExe nixos/libeufin-bank: move to own dir nixos/libeufin: move libeufin related config into its own config file nixos/libeufin/bank: extract dbinitServiceName into var nixos/libeufin: move script to ExecStart nixos/libeufin: fix config file name nixos/taler: refactor config file nixos/taler-exchange: grant delete to taler-exchange-aggregator Would repeatedly attempt to delete in a table where it wasn't allowed to and cause insane spam in the postgres log. nixos/taler/exchange: move exchange-specific options to exchange nixos/taler: move generic taler settings into taler system module nixos/taler: import exchange in module-list.nix nixos/taler-exchange: refactor services group name nixos/taler-exchange: use taler-harness to generate coins The taler-wallet-cli does not have the deployment subcommand anymore, but the docs still say that it should be used to generate the keys. For now, the keys should be generated with taler-harness. nixos/taler-exchange: add option to enable accounts nixos/taler: add missing descriptions nixos/taler(exchange): add description & use getExe' nixos/taler(merchant): init submodule nixos/taler: use correct script for db access nixos/taler: merchant add depositcheck path nixos/taler: review suggestions nixos/taler: make runtimeDir into an option, refactor nixos/taler: init mkTalerModule nixos/taler: use mkTalerModule for exchange nixos/taler: exchange fixups nixos/taler: use mkTalerModule for merchant nixos/taler: improve how dbInit script is created nixos/taler: remove exchange enableAccounts option nixos/taler: explicitly specify psql user Sometimes the dbinit service fails to find the user. nixos/taler: add openFirewall option; install package feat: add assertions, remove throw feat(taler): use module system instead of functions Also: - remove throw from denominateConfig - rename `utils.nix` to `common.nix` feat(taler): refactor modules feat: move taler module to services/finance refactor(exchange): replace throw with assert refactor(exchange,merchant): settings options fix(taler): manpage URLs fix(exchange): public key assert refactor(taler): use configFile feat(taler): include component configs directly Makes services detect config changes better.
2024-06-27 18:47:14 +02:00
Restart = "on-failure";
RestartSec = "5s";
};
requires = [ "postgresql.service" ];
after = [ "postgresql.service" ];
};
}
];
users.groups.${groupName} = { };
systemd.tmpfiles.settings = {
"10-taler-${talerComponent}" = {
"${runtimeDir}" = {
d = {
group = groupName;
user = "nobody";
mode = "070";
};
};
};
};
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.settings."${talerComponent}".PORT ];
};
environment.systemPackages = [ cfg.package ];
services.postgresql = {
enable = true;
ensureDatabases = [ dbName ];
ensureUsers = [
nixos/taler: init module basic config set that makes the service at least start add secmod helpers and taler-global runtime dir support for includes taler denominations Only enable services if taler is enabled fix wirewatch service name use correct permissions for database schema The current permissions don't work or aren't enough and cause the wirewatch and closer services to fail. nixos/libeufin: init module libeufin: refactor module libeufin: add main service nixos/taler: configure settings using options Works, but can be refactored further taler: refactor settings options trim settings defaults to the absolutely necessary ones nixos/libeufin: refactor and move to separate dir nixos/libeufin: set defaultText nixos/libeufin: use getExe nixos/libeufin-bank: move to own dir nixos/libeufin: move libeufin related config into its own config file nixos/libeufin/bank: extract dbinitServiceName into var nixos/libeufin: move script to ExecStart nixos/libeufin: fix config file name nixos/taler: refactor config file nixos/taler-exchange: grant delete to taler-exchange-aggregator Would repeatedly attempt to delete in a table where it wasn't allowed to and cause insane spam in the postgres log. nixos/taler/exchange: move exchange-specific options to exchange nixos/taler: move generic taler settings into taler system module nixos/taler: import exchange in module-list.nix nixos/taler-exchange: refactor services group name nixos/taler-exchange: use taler-harness to generate coins The taler-wallet-cli does not have the deployment subcommand anymore, but the docs still say that it should be used to generate the keys. For now, the keys should be generated with taler-harness. nixos/taler-exchange: add option to enable accounts nixos/taler: add missing descriptions nixos/taler(exchange): add description & use getExe' nixos/taler(merchant): init submodule nixos/taler: use correct script for db access nixos/taler: merchant add depositcheck path nixos/taler: review suggestions nixos/taler: make runtimeDir into an option, refactor nixos/taler: init mkTalerModule nixos/taler: use mkTalerModule for exchange nixos/taler: exchange fixups nixos/taler: use mkTalerModule for merchant nixos/taler: improve how dbInit script is created nixos/taler: remove exchange enableAccounts option nixos/taler: explicitly specify psql user Sometimes the dbinit service fails to find the user. nixos/taler: add openFirewall option; install package feat: add assertions, remove throw feat(taler): use module system instead of functions Also: - remove throw from denominateConfig - rename `utils.nix` to `common.nix` feat(taler): refactor modules feat: move taler module to services/finance refactor(exchange): replace throw with assert refactor(exchange,merchant): settings options fix(taler): manpage URLs fix(exchange): public key assert refactor(taler): use configFile feat(taler): include component configs directly Makes services detect config changes better.
2024-06-27 18:47:14 +02:00
{
name = dbName;
ensureDBOwnership = true;
}
];
};
};
}