git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #32584 from manoj23/davfs2-v3

davfs2: create user/group davfs2 if not specified in the configuration

commit0fe97853058ae0833331ede92129f9d782c6d5ac authorPeter Simons <simons@cryp.to> dateSun 17 Dec 2017, 08:53 (9 years ago) parent2737fab9724654
2 files changed+75
nixos/modules/module-list.nix+1 nixos/modules/services/network-filesystems/davfs2.nix+74
nixos/modules/module-list.nix+1
@@ -402,6 +402,7 @@
402402 ./services/monitoring/zabbix-agent.nix
403403 ./services/monitoring/zabbix-server.nix
404404 ./services/network-filesystems/cachefilesd.nix
405+ ./services/network-filesystems/davfs2.nix
405406 ./services/network-filesystems/drbd.nix
406407 ./services/network-filesystems/glusterfs.nix
407408 ./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+}