1 { config, pkgs, lib, ... }:
3 cfg = config.services.netatalk;
4 settingsFormat = pkgs.formats.ini { };
5 afpConfFile = settingsFormat.generate "afp.conf" cfg.settings;
10 enable = lib.mkEnableOption "the Netatalk AFP fileserver";
13 type = lib.types.port;
15 description = "TCP port to be used for AFP.";
18 settings = lib.mkOption {
19 inherit (settingsFormat) type;
22 Global = { "uam list" = "uams_guest.so"; };
25 "basedir regex" = "/home";
33 Configuration for Netatalk. See
34 {manpage}`afp.conf(5)`.
38 extmap = lib.mkOption {
39 type = lib.types.lines;
42 File name extension mappings.
43 See {manpage}`extmap.conf(5)`. for more information.
50 imports = (map (option:
51 lib.mkRemovedOptionModule [ "services" "netatalk" option ]
52 "This option was removed in favor of `services.netatalk.settings`.") [
58 config = lib.mkIf cfg.enable {
60 services.netatalk.settings.Global = {
61 "afp port" = toString cfg.port;
62 "extmap file" = "${pkgs.writeText "extmap.conf" cfg.extmap}";
65 systemd.services.netatalk = {
66 description = "Netatalk AFP fileserver for Macintosh clients";
67 unitConfig.Documentation =
68 "man:afp.conf(5) man:netatalk(8) man:afpd(8) man:cnid_metad(8) man:cnid_dbd(8)";
69 after = [ "network.target" "avahi-daemon.service" ];
70 wantedBy = [ "multi-user.target" ];
72 path = [ pkgs.netatalk ];
77 PIDFile = "/run/lock/netatalk";
78 ExecStart = "${pkgs.netatalk}/sbin/netatalk -F ${afpConfFile}";
79 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
80 ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID";
83 StateDirectory = [ "netatalk/CNID" ];
88 security.pam.services.netatalk.unixAuth = true;