blob: 037d149dcb2b6bf307193ce536425783c872860d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
{ config, lib, ... }:
with lib;
let
cfg = config.filesDir;
in
{
options = {
filesDir = {
enable = mkEnableOption "Enable the creation of a main files directory and nfs binds for it.";
mainDir = mkOption {
type = types.str;
default = "/srv/files";
description = ''
The main file dir.
'';
};
subPaths = mkOption {
type = types.listOf (types.submodule {
options = {
path = mkOption {
type = types.str;
};
group = mkOption {
type = types.str;
};
};
});
default = [];
description = ''
Subpaths to create under the files dir.
'';
};
};
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = [
"d ${cfg.mainDir} 0770 files files"
] ++ (map (dir: "d ${cfg.mainDir}/${dir.path} 0770 files ${dir.group}") cfg.subPaths);
users =
let
extraGroups = (map (dir: dir.group) cfg.subPaths);
in {
groups = {
files = {};
} // genAttrs extraGroups (group: {});
users.files = {
isNormalUser = true;
group = "files";
home = cfg.mainDir;
homeMode = "770";
inherit extraGroups;
};
};
};
}
|