···
13
+
inherit (lib.strings)
18
+
inherit (lib.attrsets)
24
+
inherit (lib.modules)
28
+
inherit (lib.options)
34
+
cfg = config.services.ax25.axports;
36
+
enabledAxports = filterAttrs (ax25Name: cfg: cfg.enable) cfg;
41
+
enable = mkEnableOption "Enables the axport interface";
43
+
package = mkPackageOption pkgs "ax25-tools" { };
47
+
example = "/dev/ttyACM0";
49
+
Location of hardware kiss tnc for this interface.
53
+
callsign = mkOption {
55
+
example = "WB6WLV-7";
57
+
The callsign of the physical interface to bind to.
61
+
description = mkOption {
63
+
# This cannot be empty since some ax25 tools cant parse /etc/ax25/axports without it
64
+
default = "NixOS managed tnc";
66
+
Free format description of this interface.
74
+
The serial port speed of this interface.
82
+
Default maximum packet size for this interface.
90
+
Default window size for this interface.
94
+
kissParams = mkOption {
95
+
type = types.nullOr types.str;
97
+
example = "-t 300 -l 10 -s 12 -r 80 -f n";
99
+
Kissattach parameters for this interface.
109
+
services.ax25.axports = mkOption {
110
+
type = types.attrsOf (types.submodule axportsOpts);
112
+
description = "Specification of one or more AX.25 ports.";
116
+
config = mkIf (enabledAxports != { }) {
118
+
environment.etc."ax25/axports" = {
119
+
text = concatStringsSep "\n" (
122
+
"${portName} ${portCfg.callsign} ${toString portCfg.baud} ${toString portCfg.paclen} ${toString portCfg.window} ${portCfg.description}"
128
+
systemd.targets.ax25-axports = {
129
+
description = "AX.25 axports group target";
132
+
systemd.services = mapAttrs' (portName: portCfg: {
133
+
name = "ax25-kissattach-${portName}";
135
+
description = "AX.25 KISS attached interface for ${portName}";
136
+
wantedBy = [ "multi-user.target" ];
137
+
before = [ "ax25-axports.target" ];
138
+
partOf = [ "ax25-axports.target" ];
141
+
ExecStart = "${portCfg.package}/bin/kissattach ${portCfg.tty} ${portName}";
143
+
postStart = optionalString (portCfg.kissParams != null) ''
144
+
${portCfg.package}/bin/kissparms -p ${portName} ${portCfg.kissParams}