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

View file

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

View file

@ -111,7 +111,7 @@ async fn try_main() -> Result<(), error::Main> {
let args = args::parse(); let args = args::parse();
// Initialize config // 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>()?; let config = raw_config.extract::<Config>()?;