about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFelix Buehler2024-08-24 22:05:36 +0200
committerFelix Buehler2024-08-30 22:59:29 +0200
commit0db184a1321a74fe289bc3d83e57fc43db726d5d (patch)
tree6a9774841921b3a3732fbd0afb62961a88b60812 /nixos
parent5b2cfbc9690b63cad900edbdac67b4c745823a91 (diff)
nixos/services.matrix-appservice-discord: remove `with lib;`
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/matrix/appservice-discord.nix53
1 files changed, 25 insertions, 28 deletions
diff --git a/nixos/modules/services/matrix/appservice-discord.nix b/nixos/modules/services/matrix/appservice-discord.nix
index 7f3a1ed3e20a..cbe265d35944 100644
--- a/nixos/modules/services/matrix/appservice-discord.nix
+++ b/nixos/modules/services/matrix/appservice-discord.nix
@@ -1,7 +1,4 @@
 { config, options, pkgs, lib, ... }:
-
-with lib;
-
 let
   dataDir = "/var/lib/matrix-appservice-discord";
   registrationFile = "${dataDir}/discord-registration.yaml";
@@ -13,14 +10,14 @@ let
 in {
   options = {
     services.matrix-appservice-discord = {
-      enable = mkEnableOption "a bridge between Matrix and Discord";
+      enable = lib.mkEnableOption "a bridge between Matrix and Discord";
 
-      package = mkPackageOption pkgs "matrix-appservice-discord" { };
+      package = lib.mkPackageOption pkgs "matrix-appservice-discord" { };
 
-      settings = mkOption rec {
-        # TODO: switch to types.config.json as prescribed by RFC42 once it's implemented
-        type = types.attrs;
-        apply = recursiveUpdate default;
+      settings = lib.mkOption rec {
+        # TODO: switch to lib.types.config.json as prescribed by RFC42 once it's implemented
+        type = lib.types.attrs;
+        apply = lib.recursiveUpdate default;
         default = {
           database = {
             filename = "${dataDir}/discord.db";
@@ -33,7 +30,7 @@ in {
             botToken = "";
           };
         };
-        example = literalExpression ''
+        example = lib.literalExpression ''
           {
             bridge = {
               domain = "public-domain.tld";
@@ -55,8 +52,8 @@ in {
         '';
       };
 
-      environmentFile = mkOption {
-        type = types.nullOr types.path;
+      environmentFile = lib.mkOption {
+        type = lib.types.nullOr lib.types.path;
         default = null;
         description = ''
           File containing environment variables to be passed to the matrix-appservice-discord service,
@@ -66,36 +63,36 @@ in {
         '';
       };
 
-      url = mkOption {
-        type = types.str;
+      url = lib.mkOption {
+        type = lib.types.str;
         default = "http://localhost:${toString cfg.port}";
-        defaultText = literalExpression ''"http://localhost:''${toString config.${opt.port}}"'';
+        defaultText = lib.literalExpression ''"http://localhost:''${toString config.${opt.port}}"'';
         description = ''
           The URL where the application service is listening for HS requests.
         '';
       };
 
-      port = mkOption {
-        type = types.port;
+      port = lib.mkOption {
+        type = lib.types.port;
         default = 9005; # from https://github.com/Half-Shot/matrix-appservice-discord/blob/master/package.json#L11
         description = ''
           Port number on which the bridge should listen for internal communication with the Matrix homeserver.
         '';
       };
 
-      localpart = mkOption {
-        type = with types; nullOr str;
+      localpart = lib.mkOption {
+        type = with lib.types; nullOr str;
         default = null;
         description = ''
           The user_id localpart to assign to the AS.
         '';
       };
 
-      serviceDependencies = mkOption {
-        type = with types; listOf str;
-        default = optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
-        defaultText = literalExpression ''
-          optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
+      serviceDependencies = lib.mkOption {
+        type = with lib.types; listOf str;
+        default = lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit;
+        defaultText = lib.literalExpression ''
+          lib.optional config.services.matrix-synapse.enable config.services.matrix-synapse.serviceUnit
         '';
         description = ''
           List of Systemd services to require and wait for when starting the application service,
@@ -105,7 +102,7 @@ in {
     };
   };
 
-  config = mkIf cfg.enable {
+  config = lib.mkIf cfg.enable {
     systemd.services.matrix-appservice-discord = {
       description = "A bridge between Matrix and Discord.";
 
@@ -117,8 +114,8 @@ in {
         if [ ! -f '${registrationFile}' ]; then
           ${cfg.package}/bin/matrix-appservice-discord \
             --generate-registration \
-            --url=${escapeShellArg cfg.url} \
-            ${optionalString (cfg.localpart != null) "--localpart=${escapeShellArg cfg.localpart}"} \
+            --url=${lib.escapeShellArg cfg.url} \
+            ${lib.optionalString (cfg.localpart != null) "--localpart=${lib.escapeShellArg cfg.localpart}"} \
             --config='${settingsFile}' \
             --file='${registrationFile}'
         fi
@@ -151,5 +148,5 @@ in {
     };
   };
 
-  meta.maintainers = with maintainers; [ pacien ];
+  meta.maintainers = with lib.maintainers; [ pacien ];
 }