Unverified Commit 90c90044 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

hylafaxplus: 7.0.9 -> 7.0.10, misc improvements (also module) (#376418)

parents 93c5687d 39003ad9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
  ];

  config = lib.modules.mkIf config.services.hylafax.enable {
    environment.systemPackages = [ pkgs.hylafaxplus ];
    environment.systemPackages = [ config.services.hylafax.package ];
    users.users.uucp = {
      uid = config.ids.uids.uucp;
      group = "uucp";
+3 −3
Original line number Diff line number Diff line
{ pkgs, ... }:
{ pkgs, lib, ... }:

# see man:hylafax-config(5)

@@ -16,7 +16,7 @@
  SessionTracing = "0x78701";
  UUCPLockDir = "/var/lock";

  SendPageCmd = "${pkgs.coreutils}/bin/false"; # prevent pager transmit
  SendUUCPCmd = "${pkgs.coreutils}/bin/false"; # prevent UUCP transmit
  SendPageCmd = lib.getExe' pkgs.coreutils "false"; # prevent pager transmit
  SendUUCPCmd = lib.getExe' pkgs.coreutils "false"; # prevent UUCP transmit

}
+15 −5
Original line number Diff line number Diff line
@@ -7,20 +7,28 @@

let

  inherit (lib.options) literalExpression mkEnableOption mkOption;
  inherit (lib)
    getExe'
    literalExpression
    mkDefault
    mkEnableOption
    mkIf
    mkMerge
    mkOption
    mkPackageOption
    ;
  inherit (lib.types)
    attrsOf
    bool
    enum
    ints
    lines
    attrsOf
    nonEmptyStr
    nullOr
    path
    str
    submodule
    ;
  inherit (lib.modules) mkDefault mkIf mkMerge;

  commonDescr = ''
    Values can be either strings or integers
@@ -104,11 +112,11 @@ let
      # Otherwise, we use `false` to provoke
      # an error if hylafax tries to use it.
      c.sendmailPath = mkMerge [
        (mkIfDefault noWrapper "${pkgs.coreutils}/bin/false")
        (mkIfDefault noWrapper (getExe' pkgs.coreutils "false"))
        (mkIfDefault (!noWrapper) "${wrapperDir}/${program}")
      ];
      importDefaultConfig =
        file: lib.attrsets.mapAttrs (lib.trivial.const mkDefault) (import file { inherit pkgs; });
        file: lib.attrsets.mapAttrs (lib.trivial.const mkDefault) (import file { inherit lib pkgs; });
      c.commonModemConfig = importDefaultConfig ./modem-default.nix;
      c.faxqConfig = importDefaultConfig ./faxq-default.nix;
      c.hfaxdConfig = importDefaultConfig ./hfaxd-default.nix;
@@ -136,6 +144,8 @@ in

    enable = mkEnableOption "HylaFAX server";

    package = mkPackageOption pkgs "HylaFAX" { default = "hylafaxplus"; };

    autostart = mkOption {
      type = bool;
      default = true;
+2 −2
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ touch clientlog faxcron.lastrun xferfaxlog
chown @faxuser@:@faxgroup@ clientlog faxcron.lastrun xferfaxlog

# create symlinks for frozen directories/files
lnsym --target-directory=. "@hylafaxplus@"/spool/{COPYRIGHT,bin,config}
lnsym --target-directory=. "@package@"/spool/{COPYRIGHT,bin,config}

# create empty temporary directories
update --mode=0700 -d client dev status
@@ -93,7 +93,7 @@ install -d "@spoolAreaPath@/etc"
cd "@spoolAreaPath@/etc"

# create symlinks to all files in template's etc
lnsym --target-directory=. "@hylafaxplus@/spool/etc"/*
lnsym --target-directory=. "@package@/spool/etc"/*

# set LOCKDIR in setup.cache
sed --regexp-extended 's|^(UUCP_LOCKDIR=).*$|\1'"'@lockPath@'|g" --in-place setup.cache
+44 −28
Original line number Diff line number Diff line
@@ -7,12 +7,29 @@

let

  inherit (lib) mkIf mkMerge;
  inherit (lib) concatStringsSep optionalString;
  inherit (lib)
    concatLines
    escapeShellArgs
    mkIf
    mkMerge
    optional
    ;
  inherit (lib.cli) toGNUCommandLine;

  cfg = config.services.hylafax;
  mapModems = lib.forEach (lib.attrValues cfg.modems);

  mkSpoolCmd =
    prefix: program: posArg: options:
    let
      start = "${prefix}${cfg.package}/spool/bin/${program}";
      optionsList = toGNUCommandLine { mkOptionName = k: "-${k}"; } (
        { q = cfg.spoolAreaPath; } // options
      );
      posArgList = optional (posArg != null) posArg;
    in
    "${start} ${escapeShellArgs (optionsList ++ posArgList)}";

  mkConfigFile =
    name: conf:
    # creates hylafax config file,
@@ -25,7 +42,7 @@ let
      include = mkLines { Include = conf.Include or [ ]; };
      other = mkLines (conf // { Include = [ ]; });
    in
    pkgs.writeText "hylafax-config${name}" (concatStringsSep "\n" (include ++ other));
    pkgs.writeText "hylafax-config${name}" (concatLines (include ++ other));

  globalConfigPath = mkConfigFile "" cfg.faxqConfig;

@@ -37,7 +54,7 @@ let
        { name, type, ... }@modem:
        ''
          # check if modem config file exists:
          test -f "${pkgs.hylafaxplus}/spool/config/${type}"
          test -f "${cfg.package}/spool/config/${type}"
          ln \
            --symbolic \
            --no-target-directory \
@@ -47,7 +64,7 @@ let
    in
    pkgs.runCommand "hylafax-config-modems" {
      preferLocalBuild = true;
    } ''mkdir --parents "$out/" ${concatStringsSep "\n" (mapModems mkLine)}'';
    } ''mkdir --parents "$out/" ${concatLines (mapModems mkLine)}'';

  setupSpoolScript = pkgs.replaceVarsWith {
    name = "hylafax-setup-spool.sh";
@@ -58,8 +75,8 @@ let
      faxgroup = "uucp";
      lockPath = "/var/lock";
      inherit globalConfigPath modemConfigPath;
      inherit (cfg) spoolAreaPath userAccessFile;
      inherit (pkgs) hylafaxplus runtimeShell;
      inherit (cfg) package spoolAreaPath userAccessFile;
      inherit (pkgs) runtimeShell;
    };
  };

@@ -155,7 +172,7 @@ let
    wants = mapModems ({ name, ... }: "hylafax-faxgetty@${name}.service");
    wantedBy = mkIf cfg.autostart [ "multi-user.target" ];
    serviceConfig.Type = "forking";
    serviceConfig.ExecStart = ''${pkgs.hylafaxplus}/spool/bin/faxq -q "${cfg.spoolAreaPath}"'';
    serviceConfig.ExecStart = mkSpoolCmd "" "faxq" null { };
    # This delays the "readiness" of this service until
    # all modems are initialized (or a timeout is reached).
    # Otherwise, sending a fax with the fax service
@@ -165,7 +182,7 @@ let
    serviceConfig.ExecStartPost = [ "${waitFaxqScript}" ];
    # faxquit fails if the pipe is already gone
    # (e.g. the service is already stopping)
    serviceConfig.ExecStop = ''-${pkgs.hylafaxplus}/spool/bin/faxquit -q "${cfg.spoolAreaPath}"'';
    serviceConfig.ExecStop = mkSpoolCmd "-" "faxquit" null { };
    # disable some systemd hardening settings
    serviceConfig.PrivateDevices = null;
    serviceConfig.RestrictRealtime = null;
@@ -178,7 +195,10 @@ let
    requires = [ "hylafax-faxq.service" ];
    serviceConfig.StandardInput = "socket";
    serviceConfig.StandardOutput = "socket";
    serviceConfig.ExecStart = ''${pkgs.hylafaxplus}/spool/bin/hfaxd -q "${cfg.spoolAreaPath}" -d -I'';
    serviceConfig.ExecStart = mkSpoolCmd "" "hfaxd" null {
      d = true;
      I = true;
    };
    unitConfig.RequiresMountsFor = [ cfg.userAccessFile ];
    # disable some systemd hardening settings
    serviceConfig.PrivateDevices = null;
@@ -192,13 +212,11 @@ let
    requires = [ "hylafax-spool.service" ];
    wantedBy = mkIf cfg.faxcron.enable.spoolInit requires;
    startAt = mkIf (cfg.faxcron.enable.frequency != null) cfg.faxcron.enable.frequency;
    serviceConfig.ExecStart = concatStringsSep " " [
      "${pkgs.hylafaxplus}/spool/bin/faxcron"
      ''-q "${cfg.spoolAreaPath}"''
      ''-info ${toString cfg.faxcron.infoDays}''
      ''-log  ${toString cfg.faxcron.logDays}''
      ''-rcv  ${toString cfg.faxcron.rcvDays}''
    ];
    serviceConfig.ExecStart = mkSpoolCmd "" "faxcron" null {
      info = cfg.faxcron.infoDays;
      log = cfg.faxcron.logDays;
      rcv = cfg.faxcron.rcvDays;
    };
  };

  services.hylafax-faxqclean = rec {
@@ -208,15 +226,13 @@ let
    requires = [ "hylafax-spool.service" ];
    wantedBy = mkIf cfg.faxqclean.enable.spoolInit requires;
    startAt = mkIf (cfg.faxqclean.enable.frequency != null) cfg.faxqclean.enable.frequency;
    serviceConfig.ExecStart = concatStringsSep " " [
      "${pkgs.hylafaxplus}/spool/bin/faxqclean"
      ''-q "${cfg.spoolAreaPath}"''
      "-v"
      (optionalString (cfg.faxqclean.archiving != "never") "-a")
      (optionalString (cfg.faxqclean.archiving == "always") "-A")
      ''-j ${toString (cfg.faxqclean.doneqMinutes * 60)}''
      ''-d ${toString (cfg.faxqclean.docqMinutes * 60)}''
    ];
    serviceConfig.ExecStart = mkSpoolCmd "" "faxqclean" null {
      v = true;
      a = cfg.faxqclean.archiving != "never";
      A = cfg.faxqclean.archiving == "always";
      j = 60 * cfg.faxqclean.doneqMinutes;
      d = 60 * cfg.faxqclean.docqMinutes;
    };
  };

  mkFaxgettyService =
@@ -238,10 +254,10 @@ let
      serviceConfig.Restart = "always";
      serviceConfig.KillMode = "process";
      serviceConfig.IgnoreSIGPIPE = false;
      serviceConfig.ExecStart = ''-${pkgs.hylafaxplus}/spool/bin/faxgetty -q "${cfg.spoolAreaPath}" /dev/%I'';
      serviceConfig.ExecStart = mkSpoolCmd "-" "faxgetty" "/dev/%I" { };
      # faxquit fails if the pipe is already gone
      # (e.g. the service is already stopping)
      serviceConfig.ExecStop = ''-${pkgs.hylafaxplus}/spool/bin/faxquit -q "${cfg.spoolAreaPath}" %I'';
      serviceConfig.ExecStop = mkSpoolCmd "-" "faxquit" "%I" { };
      # disable some systemd hardening settings
      serviceConfig.PrivateDevices = null;
      serviceConfig.RestrictRealtime = null;
Loading