2017-12-10 01:55:05 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2024-03-18 21:01:29 +00:00
|
|
|
toStr = value:
|
|
|
|
if true == value then "yes"
|
|
|
|
else if false == value then "no"
|
|
|
|
else toString value;
|
|
|
|
|
2017-12-10 01:55:05 +00:00
|
|
|
cfg = config.services.davfs2;
|
2024-03-18 21:01:29 +00:00
|
|
|
format = pkgs.formats.toml { };
|
|
|
|
configFile = let
|
|
|
|
settings = mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings;
|
|
|
|
in pkgs.writeText "davfs2.conf" ''
|
|
|
|
${concatStringsSep "\n" settings}
|
2017-12-10 01:55:05 +00:00
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
2024-03-18 21:01:29 +00:00
|
|
|
|
2017-12-10 01:55:05 +00:00
|
|
|
options.services.davfs2 = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-08 22:41:30 +00:00
|
|
|
description = ''
|
2017-12-10 01:55:05 +00:00
|
|
|
Whether to enable davfs2.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
davUser = mkOption {
|
2019-08-08 20:48:27 +00:00
|
|
|
type = types.str;
|
2017-12-10 01:55:05 +00:00
|
|
|
default = "davfs2";
|
2024-04-08 22:41:30 +00:00
|
|
|
description = ''
|
2017-12-10 01:55:05 +00:00
|
|
|
When invoked by root the mount.davfs daemon will run as this user.
|
|
|
|
Value must be given as name, not as numerical id.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
davGroup = mkOption {
|
2019-08-08 20:48:27 +00:00
|
|
|
type = types.str;
|
2017-12-10 01:55:05 +00:00
|
|
|
default = "davfs2";
|
2024-04-08 22:41:30 +00:00
|
|
|
description = ''
|
2017-12-10 01:55:05 +00:00
|
|
|
The group of the running mount.davfs daemon. Ordinary users must be
|
|
|
|
member of this group in order to mount a davfs2 file system. Value must
|
|
|
|
be given as name, not as numerical id.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
kernel_fs coda
|
|
|
|
proxy foo.bar:8080
|
|
|
|
use_locks 0
|
|
|
|
'';
|
2024-04-08 22:41:30 +00:00
|
|
|
description = ''
|
2017-12-10 01:55:05 +00:00
|
|
|
Extra lines appended to the configuration of davfs2.
|
2024-03-18 21:01:29 +00:00
|
|
|
See {manpage}`davfs2.conf(5)` for available settings.
|
|
|
|
|
|
|
|
**Note**: Please pass structured settings via
|
|
|
|
{option}`settings` instead, this option
|
|
|
|
will get deprecated in the future.
|
|
|
|
'' ;
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = types.submodule {
|
|
|
|
freeformType = format.type;
|
|
|
|
};
|
|
|
|
default = {};
|
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
kernel_fs = "coda";
|
|
|
|
proxy = "foo.bar:8080";
|
|
|
|
use_locks = 0;
|
|
|
|
}
|
|
|
|
'';
|
2024-04-08 22:41:30 +00:00
|
|
|
description = ''
|
2024-03-18 21:01:29 +00:00
|
|
|
Extra settings appended to the configuration of davfs2.
|
|
|
|
See {manpage}`davfs2.conf(5)` for available settings.
|
2017-12-10 01:55:05 +00:00
|
|
|
'' ;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-03-18 21:01:29 +00:00
|
|
|
|
2024-04-08 22:33:55 +00:00
|
|
|
warnings = lib.optional (cfg.extraConfig != "") ''
|
2024-04-08 22:36:23 +00:00
|
|
|
services.davfs2.extraConfig will be deprecated in future releases;
|
|
|
|
please use services.davfs2.settings instead.
|
2024-03-18 21:01:29 +00:00
|
|
|
'';
|
|
|
|
|
2017-12-10 01:55:05 +00:00
|
|
|
environment.systemPackages = [ pkgs.davfs2 ];
|
2024-03-18 21:01:29 +00:00
|
|
|
environment.etc."davfs2/davfs2.conf".source = configFile;
|
|
|
|
|
|
|
|
services.davfs2.settings = {
|
|
|
|
dav_user = cfg.davUser;
|
|
|
|
dav_group = cfg.davGroup;
|
|
|
|
};
|
2017-12-10 01:55:05 +00:00
|
|
|
|
2019-09-14 17:51:29 +00:00
|
|
|
users.groups = optionalAttrs (cfg.davGroup == "davfs2") {
|
|
|
|
davfs2.gid = config.ids.gids.davfs2;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users = optionalAttrs (cfg.davUser == "davfs2") {
|
|
|
|
davfs2 = {
|
|
|
|
createHome = false;
|
|
|
|
group = cfg.davGroup;
|
|
|
|
uid = config.ids.uids.davfs2;
|
|
|
|
description = "davfs2 user";
|
|
|
|
};
|
|
|
|
};
|
2017-12-10 01:55:05 +00:00
|
|
|
|
2021-05-10 13:54:52 +00:00
|
|
|
security.wrappers."mount.davfs" = {
|
|
|
|
program = "mount.davfs";
|
|
|
|
source = "${pkgs.davfs2}/bin/mount.davfs";
|
|
|
|
owner = "root";
|
|
|
|
group = cfg.davGroup;
|
|
|
|
setuid = true;
|
|
|
|
permissions = "u+rx,g+x";
|
|
|
|
};
|
|
|
|
|
|
|
|
security.wrappers."umount.davfs" = {
|
|
|
|
program = "umount.davfs";
|
|
|
|
source = "${pkgs.davfs2}/bin/umount.davfs";
|
|
|
|
owner = "root";
|
|
|
|
group = cfg.davGroup;
|
|
|
|
setuid = true;
|
|
|
|
permissions = "u+rx,g+x";
|
|
|
|
};
|
|
|
|
|
2017-12-10 01:55:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|