From 75929b461294e02c24c2b98f36c42ae6ec7fc08f Mon Sep 17 00:00:00 2001 From: matthewcroughan Date: Tue, 15 Jul 2025 21:00:29 +0100 Subject: [PATCH] nixos/atalkd: init --- nixos/doc/manual/redirects.json | 6 ++ nixos/modules/module-list.nix | 1 + nixos/modules/services/networking/atalkd.md | 18 ++++ nixos/modules/services/networking/atalkd.nix | 98 ++++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 nixos/modules/services/networking/atalkd.md create mode 100644 nixos/modules/services/networking/atalkd.nix diff --git a/nixos/doc/manual/redirects.json b/nixos/doc/manual/redirects.json index fffee51d25b0..adbf2b625ce7 100644 --- a/nixos/doc/manual/redirects.json +++ b/nixos/doc/manual/redirects.json @@ -851,6 +851,12 @@ "modules-services-akkoma-distributed-deployment": [ "index.html#modules-services-akkoma-distributed-deployment" ], + "module-services-atalkd": [ + "index.html#module-services-atalkd" + ], + "module-services-atalkd-basic-usage": [ + "index.html#module-services-atalkd-basic-usage" + ], "module-services-systemd-lock-handler": [ "index.html#module-services-systemd-lock-handler" ], diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 0ec81e5bcb7b..e8ffa325160b 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1069,6 +1069,7 @@ ./services/networking/anubis.nix ./services/networking/aria2.nix ./services/networking/asterisk.nix + ./services/networking/atalkd.nix ./services/networking/atftpd.nix ./services/networking/atticd.nix ./services/networking/autossh.nix diff --git a/nixos/modules/services/networking/atalkd.md b/nixos/modules/services/networking/atalkd.md new file mode 100644 index 000000000000..3b999680ce33 --- /dev/null +++ b/nixos/modules/services/networking/atalkd.md @@ -0,0 +1,18 @@ +# atalkd {#module-services-atalkd} + +atalkd (AppleTalk daemon) is a component inside of the suite of software provided by Netatalk. It allows for the creation of AppleTalk networks, typically speaking over a Linux ethernet network interface, that can still be seen by classic macintosh computers. Using the NixOS module, you can specify a set of network interfaces that you wish to speak AppleTalk on, and the corresponding ATALKD.CONF(5) values to go along with it. + +## Basic Usage {#module-services-atalkd-basic-usage} + +A minimal configuration looks like this: + +```nix +{ + services.atalkd = { + enable = true; + interfaces.wlan0.config = "-router -phase 2 -net 1 -addr 1.48 -zone \"Default\""; + }; +} +``` + +It is also valid to use atalkd without setting `services.netatalk.interfaces` to any value, only providing `services.atalkd.enable = true`. In this case it will inherit the behavior of the upstream application when an empty config file is found, which is to listen on and use all interfaces. diff --git a/nixos/modules/services/networking/atalkd.nix b/nixos/modules/services/networking/atalkd.nix new file mode 100644 index 000000000000..1f8d5e75f041 --- /dev/null +++ b/nixos/modules/services/networking/atalkd.nix @@ -0,0 +1,98 @@ +{ + config, + pkgs, + lib, + utils, + ... +}: + +let + cfg = config.services.atalkd; + + # Generate atalkd.conf only if configFile isn't manually specified + atalkdConfFile = pkgs.writeText "atalkd.conf" ( + lib.concatStringsSep "\n" ( + lib.mapAttrsToList ( + iface: ifaceCfg: iface + (if ifaceCfg.config != null then " ${ifaceCfg.config}" else "") + ) cfg.interfaces + ) + ); +in +{ + options.services.atalkd = { + enable = lib.mkEnableOption "the AppleTalk daemon"; + + configFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; + default = atalkdConfFile; + defaultText = "/nix/store/xxx-atalkd.conf"; + description = '' + Optional path to a custom `atalkd.conf` file. When set, this overrides the generated + configuration from `services.atalkd.interfaces`. + ''; + }; + + interfaces = lib.mkOption { + description = "Per-interface configuration for atalkd."; + type = lib.types.attrsOf ( + lib.types.submodule { + options.config = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + description = "Optional configuration string for this interface."; + }; + } + ); + default = { }; + }; + }; + + config = + let + interfaces = map (iface: "sys-subsystem-net-devices-${utils.escapeSystemdPath iface}.device") ( + builtins.attrNames cfg.interfaces + ); + in + lib.mkIf cfg.enable { + system.requiredKernelConfig = [ + (config.lib.kernelConfig.isEnabled "APPLETALK") + ]; + systemd.services.netatalk.partOf = [ "atalkd.service" ]; + systemd.services.netatalk.after = interfaces; + systemd.services.netatalk.requires = interfaces; + systemd.services.atalkd = + let + interfaces = map (iface: "sys-subsystem-net-devices-${utils.escapeSystemdPath iface}.device") ( + builtins.attrNames cfg.interfaces + ); + in + { + + description = "atalkd AppleTalk daemon"; + unitConfig.Documentation = "man:atalkd.conf(5) man:atalkd(8)"; + after = interfaces; + wants = [ "network.target" ]; + before = [ "netatalk.service" ]; + requires = interfaces; + + wantedBy = [ "multi-user.target" ]; + + path = [ pkgs.netatalk ]; + + serviceConfig = { + Type = "forking"; + GuessMainPID = "no"; + DynamicUser = true; + AmbientCapabilities = [ "CAP_NET_ADMIN" ]; + RuntimeDirectory = "atalkd"; + PIDFile = "/run/atalkd/atalkd"; + BindPaths = [ "/run/atalkd:/run/lock" ]; + ExecStart = "${pkgs.netatalk}/bin/atalkd -f ${cfg.configFile}"; + Restart = "always"; + }; + }; + }; + + meta.maintainers = with lib.maintainers; [ matthewcroughan ]; + meta.doc = ./atalkd.md; +}