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