From e71c09b8f8f576d97e7b6cc1019f215429fcdb2f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Wed, 28 Aug 2024 21:19:00 +0200 Subject: [PATCH] nixos/services.webdav-server-rs: remove `with lib;` --- .../network-filesystems/webdav-server-rs.nix | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/network-filesystems/webdav-server-rs.nix b/nixos/modules/services/network-filesystems/webdav-server-rs.nix index 7e83d78db5b0..31f641a82d79 100644 --- a/nixos/modules/services/network-filesystems/webdav-server-rs.nix +++ b/nixos/modules/services/network-filesystems/webdav-server-rs.nix @@ -1,10 +1,8 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.services.webdav-server-rs; format = pkgs.formats.toml { }; - settings = recursiveUpdate + settings = lib.recursiveUpdate { server.uid = config.users.users."${cfg.user}".uid; server.gid = config.users.groups."${cfg.group}".gid; @@ -14,27 +12,27 @@ in { options = { services.webdav-server-rs = { - enable = mkEnableOption "WebDAV server"; + enable = lib.mkEnableOption "WebDAV server"; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "webdav"; description = "User to run under when setuid is not enabled."; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "webdav"; description = "Group to run under when setuid is not enabled."; }; - debug = mkOption { - type = types.bool; + debug = lib.mkOption { + type = lib.types.bool; default = false; description = "Enable debug mode."; }; - settings = mkOption { + settings = lib.mkOption { type = format.type; default = { }; description = '' @@ -42,7 +40,7 @@ in options can be found at [here](https://github.com/miquels/webdav-server-rs/blob/master/webdav-server.toml). ''; - example = literalExpression '' + example = lib.literalExpression '' { server.listen = [ "0.0.0.0:4918" "[::]:4918" ]; accounts = { @@ -75,8 +73,8 @@ in ''; }; - configFile = mkOption { - type = types.path; + configFile = lib.mkOption { + type = lib.types.path; default = format.generate "webdav-server.toml" settings; defaultText = "Config file generated from services.webdav-server-rs.settings"; description = '' @@ -88,19 +86,19 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { - assertion = hasAttr cfg.user config.users.users && config.users.users."${cfg.user}".uid != null; + assertion = lib.hasAttr cfg.user config.users.users && config.users.users."${cfg.user}".uid != null; message = "users.users.${cfg.user} and users.users.${cfg.user}.uid must be defined."; } { - assertion = hasAttr cfg.group config.users.groups && config.users.groups."${cfg.group}".gid != null; + assertion = lib.hasAttr cfg.group config.users.groups && config.users.groups."${cfg.group}".gid != null; message = "users.groups.${cfg.group} and users.groups.${cfg.group}.gid must be defined."; } ]; - users.users = optionalAttrs (cfg.user == "webdav") { + users.users = lib.optionalAttrs (cfg.user == "webdav") { webdav = { description = "WebDAV user"; group = cfg.group; @@ -108,7 +106,7 @@ in }; }; - users.groups = optionalAttrs (cfg.group == "webdav") { + users.groups = lib.optionalAttrs (cfg.group == "webdav") { webdav.gid = config.ids.gids.webdav; }; @@ -146,5 +144,5 @@ in }; }; - meta.maintainers = with maintainers; [ pmy ]; + meta.maintainers = with lib.maintainers; [ pmy ]; }