nixos/services.webdav: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-28 21:19:00 +02:00 committed by Jörg Thalheim
parent e71c09b8f8
commit 9ffa253b87

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.webdav; cfg = config.services.webdav;
format = pkgs.formats.yaml { }; format = pkgs.formats.yaml { };
@ -8,21 +6,21 @@ in
{ {
options = { options = {
services.webdav = { services.webdav = {
enable = mkEnableOption "WebDAV server"; enable = lib.mkEnableOption "WebDAV server";
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "webdav"; default = "webdav";
description = "User account under which WebDAV runs."; description = "User account under which WebDAV runs.";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "webdav"; default = "webdav";
description = "Group under which WebDAV runs."; description = "Group under which WebDAV runs.";
}; };
settings = mkOption { settings = lib.mkOption {
type = format.type; type = format.type;
default = { }; default = { };
description = '' description = ''
@ -36,7 +34,7 @@ in
[EnvironmentFile](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=). [EnvironmentFile](https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=).
This prevents adding secrets to the world-readable Nix store. This prevents adding secrets to the world-readable Nix store.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ {
address = "0.0.0.0"; address = "0.0.0.0";
port = 8080; port = 8080;
@ -53,8 +51,8 @@ in
''; '';
}; };
configFile = mkOption { configFile = lib.mkOption {
type = types.path; type = lib.types.path;
default = format.generate "webdav.yaml" cfg.settings; default = format.generate "webdav.yaml" cfg.settings;
defaultText = "Config file generated from services.webdav.settings"; defaultText = "Config file generated from services.webdav.settings";
description = '' description = ''
@ -64,8 +62,8 @@ in
example = "/etc/webdav/config.yaml"; example = "/etc/webdav/config.yaml";
}; };
environmentFile = mkOption { environmentFile = lib.mkOption {
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
description = '' description = ''
Environment file as defined in {manpage}`systemd.exec(5)`. Environment file as defined in {manpage}`systemd.exec(5)`.
@ -74,8 +72,8 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.users = mkIf (cfg.user == "webdav") { users.users = lib.mkIf (cfg.user == "webdav") {
webdav = { webdav = {
description = "WebDAV daemon user"; description = "WebDAV daemon user";
group = cfg.group; group = cfg.group;
@ -83,7 +81,7 @@ in
}; };
}; };
users.groups = mkIf (cfg.group == "webdav") { users.groups = lib.mkIf (cfg.group == "webdav") {
webdav.gid = config.ids.gids.webdav; webdav.gid = config.ids.gids.webdav;
}; };
@ -96,10 +94,10 @@ in
Restart = "on-failure"; Restart = "on-failure";
User = cfg.user; User = cfg.user;
Group = cfg.group; Group = cfg.group;
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ]; EnvironmentFile = lib.mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
}; };
}; };
}; };
meta.maintainers = with maintainers; [ pmy ]; meta.maintainers = with lib.maintainers; [ pmy ];
} }