No description
Find a file
2025-08-10 17:27:28 +02:00
nixos Update README 2025-08-10 17:22:13 +02:00
pkgs Update PTLIBPLUGINDIR 2025-08-10 14:41:46 +02:00
.gitignore Init 2025-06-21 20:48:13 +02:00
flake.lock Update README 2025-08-10 17:22:13 +02:00
flake.nix Update README 2025-08-10 17:22:13 +02:00
README.md Update README 2025-08-10 17:27:28 +02:00

t38modem

Just t38modem (https://github.com/hehol/t38modem) packaged for NixOS.

This flake packages two NixOS modules:

Example configuration

# configuration.nix
{ inputs, lib, config, ... }:

let
  ttyPrefix = "ttyFAX";
in
{
  imports = [
    inputs.t38modem.nixosModules.t38modem
    inputs.t38modem.nixosModules.hylafax
  ];

  # with sops-nix
  sops.secrets =
    let
      modem = config.services.t38modem.modems.${ttyPrefix};
      data = {
        restartUnits = [ modem.serviceName ];
      };
    in
    {
      "t38modem/sip/username" = data;
      "t38modem/sip/password" = data;
      "t38modem/sip/server" = data;
      "t38modem/stunServer" = data;
    };

  services.t38modem = {
    enable = true;
    modems."${ttyPrefix}" = {
      sip = {
        # plain `username`, `password`, `server` also supported
        usernameFile = config.sops.secrets."t38modem/sip/username".path;
        passwordFile = config.sops.secrets."t38modem/sip/password".path;
        serverFile = config.sops.secrets."t38modem/sip/server".path;
      };
      # plain `stunServer` also supported
      stunServerFile = config.sops.secrets."t38modem/stunServer".path;
      count = 1; # number of virtual modems to be spawned: /dev/${ttyPrefix}{1..count}
      after = [ "sops-nix.service" ];
    };
  };

  # only allow local connections to hfaxd
  environment.etc."hosts.hfaxd" = {
    mode = "0600";
    user = "uucp";
    text = ''
      127.0.0.1
      localhost
    '';
  };

  services.hylafax = {
    enable = true;
    hfaxdConfig = { };
    modems = lib.listToAttrs (
      map (
        device:
        lib.nameValuePair device {
          type = "t38modem";
          service = config.services.t38modem.modems."${ttyPrefix}".serviceName;
          config = rec {
            FAXNumber = "7899";
            LocalIdentifier = "FaxMachine ${FAXNumber}";

            # enable caller ID reporting (https://github.com/hehol/t38modem/blob/master/HylaFAX/config.ttyx)
            ModemResetCmds = "AT#CID=10";
            RingsBeforeAnswer = 2;
            CIDNumber = ''"NMBR = "'';
            CIDName = ''"NDID = "'';
          };
        }
      ) config.services.t38modem.modems."${ttyPrefix}".devices
    );
  };
}