drop nested config

This functionality was never actually used AFAICT, as no way to provide
alternate profiles was ever provided.

This changes the configuration format to remove the `[global]` section,
everything that was previously under that namespace is now at the top
level.
This commit is contained in:
Charles Hall 2024-06-06 21:58:33 -07:00
parent 44088852cf
commit 003c0a4928
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
3 changed files with 10 additions and 11 deletions

View file

@ -29,21 +29,21 @@ in
type = types.submodule {
freeformType = format.type;
options = {
global.address = lib.mkOption {
address = lib.mkOption {
type = types.nonEmptyStr;
description = ''
The local IP address to bind to.
'';
default = "::1";
};
global.conduit_compat = lib.mkOption {
conduit_compat = lib.mkOption {
type = types.bool;
description = ''
Whether to operate as a drop-in replacement for Conduit.
'';
default = false;
};
global.database_path = lib.mkOption {
database_path = lib.mkOption {
type = types.nonEmptyStr;
readOnly = true;
description = ''
@ -52,11 +52,11 @@ in
Note that this is read-only because this module makes use of
systemd's `StateDirectory` option.
'';
default = if cfg.settings.global.conduit_compat
default = if cfg.settings.conduit_compat
then "/var/lib/matrix-conduit"
else "/var/lib/grapevine";
};
global.port = lib.mkOption {
port = lib.mkOption {
type = types.port;
description = ''
The local port to bind to.
@ -98,14 +98,14 @@ in
RestrictNamespaces = true;
RestrictRealtime = true;
StartLimitBurst = 5;
StateDirectory = if cfg.settings.global.conduit_compat
StateDirectory = if cfg.settings.conduit_compat
then "matrix-conduit"
else "grapevine";
StateDirectoryMode = "0700";
SystemCallArchitectures = "native";
SystemCallFilter = [ "@system-service" "~@privileged" ];
UMask = "077";
User = if cfg.settings.global.conduit_compat
User = if cfg.settings.conduit_compat
then "conduit"
else "grapevine";
};

View file

@ -10,13 +10,12 @@ use crate::Result;
/// ```
/// - Global proxy
/// ```toml
/// [global.proxy]
/// [proxy]
/// global = { url = "socks5h://localhost:9050" }
/// ```
/// - Proxy some domains
/// ```toml
/// [global.proxy]
/// [[global.proxy.by_domain]]
/// [[proxy.by_domain]]
/// url = "socks5h://localhost:9050"
/// include = ["*.onion", "matrix.myspecial.onion"]
/// exclude = ["*.myspecial.onion"]

View file

@ -111,7 +111,7 @@ async fn try_main() -> Result<(), error::Main> {
let args = args::parse();
// Initialize config
let raw_config = Figment::new().merge(Toml::file(&args.config).nested());
let raw_config = Figment::new().merge(Toml::file(&args.config));
let config = raw_config.extract::<Config>()?;