git.iko.soy/typeable/nixpkgs
on master help sign in
davfs2: create user/group davfs2 if not specified in the configuration

* Add options: - enable - davUser (default: "davfs2") - davGroup (default: "davfs2) * Add davfs2 user or group if they are not specified in the configuration

commit9724654c74d868fb1ddb873a763a221c0608cdb4 authorGeorges Savoundararadj <savoundg@gmail.com> dateSat 9 Dec 2017, 17:55 (9 years ago) parent1354099
2 files changed+75
nixos/modules/module-list.nix+1 nixos/modules/services/network-filesystems/davfs2.nix+74
nixos/modules/module-list.nix+1
@@ -401,6 +401,7 @@
401401 ./services/monitoring/zabbix-agent.nix
402402 ./services/monitoring/zabbix-server.nix
403403 ./services/network-filesystems/cachefilesd.nix
404+ ./services/network-filesystems/davfs2.nix
404405 ./services/network-filesystems/drbd.nix
405406 ./services/network-filesystems/glusterfs.nix
406407 ./services/network-filesystems/kbfs.nix
nixos/modules/services/network-filesystems/davfs2.nixnew file+74
@@ -0,0 +1,74 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.davfs2;
7+ cfgFile = pkgs.writeText "davfs2.conf" ''
8+ dav_user ${cfg.davUser}
9+ dav_group ${cfg.davGroup}
10+ ${cfg.extraConfig}
11+ '';
12+in
13+{
14+ options.services.davfs2 = {
15+ enable = mkOption {
16+ type = types.bool;
17+ default = false;
18+ description = ''
19+ Whether to enable davfs2.
20+ '';
21+ };
22+
23+ davUser = mkOption {
24+ type = types.string;
25+ default = "davfs2";
26+ description = ''
27+ When invoked by root the mount.davfs daemon will run as this user.
28+ Value must be given as name, not as numerical id.
29+ '';
30+ };
31+
32+ davGroup = mkOption {
33+ type = types.string;
34+ default = "davfs2";
35+ description = ''
36+ The group of the running mount.davfs daemon. Ordinary users must be
37+ member of this group in order to mount a davfs2 file system. Value must
38+ be given as name, not as numerical id.
39+ '';
40+ };
41+
42+ extraConfig = mkOption {
43+ type = types.lines;
44+ default = "";
45+ example = ''
46+ kernel_fs coda
47+ proxy foo.bar:8080
48+ use_locks 0
49+ '';
50+ description = ''
51+ Extra lines appended to the configuration of davfs2.
52+ '' ;
53+ };
54+ };
55+
56+ config = mkIf cfg.enable {
57+ environment.systemPackages = [ pkgs.davfs2 ];
58+ environment.etc."davfs2/davfs2.conf".source = cfgFile;
59+
60+ users.extraGroups = optionalAttrs (cfg.davGroup == "davfs2") (singleton {
61+ name = "davfs2";
62+ gid = config.ids.gids.davfs2;
63+ });
64+
65+ users.extraUsers = optionalAttrs (cfg.davUser == "davfs2") (singleton {
66+ name = "davfs2";
67+ createHome = false;
68+ group = cfg.davGroup;
69+ uid = config.ids.uids.davfs2;
70+ description = "davfs2 user";
71+ });
72+ };
73+
74+}