nixos/services.pantalaimon-headless: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-24 22:05:37 +02:00
parent ec70164f24
commit 0a78cd4f73
2 changed files with 22 additions and 26 deletions

View File

@ -1,26 +1,24 @@
{ config, lib, name, ... }:
with lib;
{
options = {
dataPath = mkOption {
type = types.path;
dataPath = lib.mkOption {
type = lib.types.path;
default = "/var/lib/pantalaimon-${name}";
description = ''
The directory where `pantalaimon` should store its state such as the database file.
'';
};
logLevel = mkOption {
type = types.enum [ "info" "warning" "error" "debug" ];
logLevel = lib.mkOption {
type = lib.types.enum [ "info" "warning" "error" "debug" ];
default = "warning";
description = ''
Set the log level of the daemon.
'';
};
homeserver = mkOption {
type = types.str;
homeserver = lib.mkOption {
type = lib.types.str;
example = "https://matrix.org";
description = ''
The URI of the homeserver that the `pantalaimon` proxy should
@ -29,8 +27,8 @@ with lib;
'';
};
ssl = mkOption {
type = types.bool;
ssl = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether or not SSL verification should be enabled for outgoing
@ -38,8 +36,8 @@ with lib;
'';
};
listenAddress = mkOption {
type = types.str;
listenAddress = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = ''
The address where the daemon will listen to client connections
@ -47,18 +45,18 @@ with lib;
'';
};
listenPort = mkOption {
type = types.port;
listenPort = lib.mkOption {
type = lib.types.port;
default = 8009;
description = ''
The port where the daemon will listen to client connections for
this homeserver. Note that the listen address/port combination
needs to be unique between different homeservers.
needs to be lib.unique between different homeservers.
'';
};
extraSettings = mkOption {
type = types.attrs;
extraSettings = lib.mkOption {
type = lib.types.attrs;
default = { };
description = ''
Extra configuration options. See

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.pantalaimon-headless;
@ -12,7 +10,7 @@ let
Notifications = false;
};
${name} = (recursiveUpdate
${name} = (lib.recursiveUpdate
{
Homeserver = instanceConfig.homeserver;
ListenAddress = instanceConfig.listenAddress;
@ -28,7 +26,7 @@ let
};
mkPantalaimonService = name: instanceConfig:
nameValuePair "pantalaimon-${name}" {
lib.nameValuePair "pantalaimon-${name}" {
description = "pantalaimon instance ${name} - E2EE aware proxy daemon for matrix clients";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
@ -48,9 +46,9 @@ let
};
in
{
options.services.pantalaimon-headless.instances = mkOption {
options.services.pantalaimon-headless.instances = lib.mkOption {
default = { };
type = types.attrsOf (types.submodule (import ./pantalaimon-options.nix));
type = lib.types.attrsOf (lib.types.submodule (import ./pantalaimon-options.nix));
description = ''
Declarative instance config.
@ -59,12 +57,12 @@ in
'';
};
config = mkIf (config.services.pantalaimon-headless.instances != { })
config = lib.mkIf (config.services.pantalaimon-headless.instances != { })
{
systemd.services = mapAttrs' mkPantalaimonService config.services.pantalaimon-headless.instances;
systemd.services = lib.mapAttrs' mkPantalaimonService config.services.pantalaimon-headless.instances;
};
meta = {
maintainers = with maintainers; [ jojosch ];
maintainers = with lib.maintainers; [ jojosch ];
};
}