···
cfg = config.services.netatalk;
9
-
extmapFile = pkgs.writeText "extmap.conf" cfg.extmap;
11
-
afpToString = x: if builtins.typeOf x == "bool"
15
-
volumeConfig = name:
16
-
let vol = getAttr name cfg.volumes; in
17
-
"[${name}]\n " + (toString (
19
-
(key: "${key} = ${afpToString (getAttr key vol)}\n")
23
-
afpConf = ''[Global]
24
-
extmap file = ${extmapFile}
25
-
afp port = ${toString cfg.port}
29
-
${if cfg.homes.enable then ''[Homes]
30
-
${optionalString (cfg.homes.path != "") "path = ${cfg.homes.path}"}
31
-
basedir regex = ${cfg.homes.basedirRegex}
32
-
${cfg.homes.extraConfig}
35
-
${toString (map volumeConfig (attrNames cfg.volumes))}
38
-
afpConfFile = pkgs.writeText "afp.conf" afpConf;
7
+
settingsFormat = pkgs.formats.ini { };
8
+
afpConfFile = settingsFormat.generate "afp.conf" cfg.settings;
···
description = "TCP port to be used for AFP.";
54
-
extraConfig = mkOption {
57
-
example = "uam list = uams_guest.so";
21
+
settings = mkOption {
22
+
inherit (settingsFormat) type;
25
+
Global = { "uam list" = "uams_guest.so"; };
28
+
"basedir regex" = "/home";
31
+
path = "/srv/volume";
59
-
Lines of configuration to add to the <literal>[Global]</literal> section.
60
-
See <literal>man apf.conf</literal> for more information.
68
-
description = "Enable sharing of the UNIX server user home directories.";
74
-
example = "afp-data";
75
-
description = "Share not the whole user home but this subdirectory path.";
78
-
basedirRegex = mkOption {
81
-
description = "Regex which matches the parent directory of the user homes.";
84
-
extraConfig = mkOption {
88
-
Lines of configuration to add to the <literal>[Homes]</literal> section.
89
-
See <literal>man apf.conf</literal> for more information.
94
-
volumes = mkOption {
96
-
type = types.attrsOf (types.attrsOf types.unspecified);
99
-
Set of AFP volumes to export.
100
-
See <literal>man apf.conf</literal> for more information.
102
-
example = literalExample ''
105
-
"read only" = true;
106
-
"hosts allow" = "10.1.0.0/16 10.2.1.100 2001:0db8:1234::/48";
36
+
Configuration for Netatalk. See
37
+
<citerefentry><refentrytitle>afp.conf</refentrytitle>
38
+
<manvolnum>5</manvolnum></citerefentry>.
···
File name extension mappings.
117
-
See <literal>man extmap.conf</literal> for more information.
47
+
See <citerefentry><refentrytitle>extmap.conf</refentrytitle>
48
+
<manvolnum>5</manvolnum></citerefentry>. for more information.
55
+
imports = (map (option:
56
+
mkRemovedOptionModule [ "services" "netatalk" option ]
57
+
"This option was removed in favor of `services.netatalk.settings`.") [
config = mkIf cfg.enable {
65
+
services.netatalk.settings.Global = {
66
+
"afp port" = toString cfg.port;
67
+
"extmap file" = "${pkgs.writeText "extmap.conf" cfg.extmap}";
systemd.services.netatalk = {
description = "Netatalk AFP fileserver for Macintosh clients";
128
-
unitConfig.Documentation = "man:afp.conf(5) man:netatalk(8) man:afpd(8) man:cnid_metad(8) man:cnid_dbd(8)";
72
+
unitConfig.Documentation =
73
+
"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" ];
···
PIDFile = "/run/lock/netatalk";
138
-
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -m 0755 -p /var/lib/netatalk/CNID";
139
-
ExecStart = "${pkgs.netatalk}/sbin/netatalk -F ${afpConfFile}";
83
+
ExecStart = "${pkgs.netatalk}/sbin/netatalk -F ${afpConfFile}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
141
-
ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID";
85
+
ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID";
88
+
StateDirectory = [ "netatalk/CNID" ];