mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
nixos/services.webdav-server-rs: remove with lib;
This commit is contained in:
parent
43235a1a61
commit
e71c09b8f8
1 changed files with 18 additions and 20 deletions
|
@ -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 ];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue