1 { config, pkgs, lib, ... }:
6 cfg = config.services.netatalk;
7 settingsFormat = pkgs.formats.ini { };
8 afpConfFile = settingsFormat.generate "afp.conf" cfg.settings;
13 enable = mkEnableOption (lib.mdDoc "the Netatalk AFP fileserver");
18 description = lib.mdDoc "TCP port to be used for AFP.";
22 inherit (settingsFormat) type;
25 Global = { "uam list" = "uams_guest.so"; };
28 "basedir regex" = "/home";
35 description = lib.mdDoc ''
36 Configuration for Netatalk. See
37 {manpage}`afp.conf(5)`.
44 description = lib.mdDoc ''
45 File name extension mappings.
46 See {manpage}`extmap.conf(5)`. for more information.
53 imports = (map (option:
54 mkRemovedOptionModule [ "services" "netatalk" option ]
55 "This option was removed in favor of `services.netatalk.settings`.") [
61 config = mkIf cfg.enable {
63 services.netatalk.settings.Global = {
64 "afp port" = toString cfg.port;
65 "extmap file" = "${pkgs.writeText "extmap.conf" cfg.extmap}";
68 systemd.services.netatalk = {
69 description = "Netatalk AFP fileserver for Macintosh clients";
70 unitConfig.Documentation =
71 "man:afp.conf(5) man:netatalk(8) man:afpd(8) man:cnid_metad(8) man:cnid_dbd(8)";
72 after = [ "network.target" "avahi-daemon.service" ];
73 wantedBy = [ "multi-user.target" ];
75 path = [ pkgs.netatalk ];
80 PIDFile = "/run/lock/netatalk";
81 ExecStart = "${pkgs.netatalk}/sbin/netatalk -F ${afpConfFile}";
82 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
83 ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID";
86 StateDirectory = [ "netatalk/CNID" ];
91 security.pam.services.netatalk.unixAuth = true;