blob: b8475c05ccb7f104b0cd93f805d4dcc65741a994 (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.netatalk;
settingsFormat = pkgs.formats.ini { };
afpConfFile = settingsFormat.generate "afp.conf" cfg.settings;
in
{
options = {
services.netatalk = {
enable = lib.mkEnableOption "the Netatalk AFP fileserver";
port = lib.mkOption {
type = lib.types.port;
default = 548;
description = "TCP port to be used for AFP.";
};
settings = lib.mkOption {
inherit (settingsFormat) type;
default = { };
example = {
Global = {
"uam list" = "uams_guest.so";
};
Homes = {
path = "afp-data";
"basedir regex" = "/home";
};
example-volume = {
path = "/srv/volume";
"read only" = true;
};
};
description = ''
Configuration for Netatalk. See
{manpage}`afp.conf(5)`.
'';
};
extmap = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
File name extension mappings.
See {manpage}`extmap.conf(5)`. for more information.
'';
};
};
};
imports = (
map
(
option:
lib.mkRemovedOptionModule [
"services"
"netatalk"
option
] "This option was removed in favor of `services.netatalk.settings`."
)
[
"extraConfig"
"homes"
"volumes"
]
);
config = lib.mkIf cfg.enable {
services.netatalk.settings.Global = {
"afp port" = toString cfg.port;
"extmap file" = "${pkgs.writeText "extmap.conf" cfg.extmap}";
};
systemd.services.netatalk = {
description = "Netatalk AFP fileserver for Macintosh clients";
unitConfig.Documentation = "man:afp.conf(5) man:netatalk(8) man:afpd(8) man:cnid_metad(8) man:cnid_dbd(8)";
after = [
"network.target"
"avahi-daemon.service"
];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.netatalk ];
serviceConfig = {
Type = "forking";
GuessMainPID = "no";
PIDFile = "/run/lock/netatalk";
ExecStart = "${pkgs.netatalk}/sbin/netatalk -F ${afpConfFile}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID";
Restart = "always";
RestartSec = 1;
StateDirectory = [ "netatalk/CNID" ];
};
};
security.pam.services.netatalk.unixAuth = true;
};
}
|