New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HylaFAX+: init at 5.5.8 #19392
HylaFAX+: init at 5.5.8 #19392
Conversation
@RamKromberg, thanks for your PR! By analyzing the history of the files in this pull request, we identified @joachifm, @edolstra and @offlinehacker to be potential reviewers. |
${pkgs.ghostscript}/bin/gs -q -sDEVICE=tiffg3 -sFONTPATH="${pkgs.ghostscript}/share/ghostscript/fonts ${pkgs.ghostscript}/share/ghostscript/${pkgs.ghostscript.version}/Resource/Init ${pkgs.ghostscript}/share/ghostscript/${pkgs.ghostscript.version}/lib ${pkgs.ghostscript}/share/ghostscript/${pkgs.ghostscript.version}/Resource/Font ${pkgs.ghostscript}/share/ghostscript/fonts ${pkgs.ghostscript}/share/fonts/default/ghostscript ${pkgs.ghostscript}/share/fonts/default/Type1 ${pkgs.ghostscript}/share/fonts/default/TrueType" /var/spool/hylafax/bin/genfontmap.ps > /var/spool/hylafax/etc/Fontmap.HylaFAX 2>/dev/null | ||
${concatStringsSep ";" (zipListsWith (a: b: "cp " + a + " /var/spool/hylafax/etc/config." + b) etcConfigDevs etcDevs)}; | ||
chmod 0755 /var/spool/hylafax | ||
ls -A /var/spool/hylafax/ | grep -v -E 'recvq|log' | ${pkgs.gawk}/bin/awk '{print "/var/spool/hylafax/"$1}' | xargs chmod -R 0755 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something with find
would be cleaner:
find /var/spool/hylafax -type d \( -path recvq -o -path log \) -prune -o -print0 | xargs -0 chmod -R 0755
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shopt -s extglob nullglob
chmod 0755 /var/spool/hylafax/!(recvq|log)/**/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 It's also good but I prefer it my way since it's easier to understand and maintain.
@joachifm I've considered this previously and decided I'd like to avoid bash-only features when possible.
Unless you guys can produce a solution that doesn't depend on regex matching (compute) or that walks only the one time (disk io), I'm sticking with the choice I find easiest to maintain.
{ | ||
${coreutils}/bin/echo -n "$* " | ||
} | ||
ttyPort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 it's the indentation faxsetup outputs. Same goes for hyla.conf, setup.cache and setup.modem.
I'd rather not touch them for diffing purposes if a future update changes them.
|
services.hylafaxp.pagesizes = mkOption { | ||
type = types.lines; | ||
default = '' | ||
# $Id: pagesizes.in 2 2005-11-11 21:32:03Z faxguy $ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file did not change since 2005. Do you think it is necessary to provide an option to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's the paper size you send.
HylaFAX usually distributes with Letter as a default but I've taken the liberty to use ISO A4 instead since that's what I, and presumably, most of the NixOS user base, uses.
Anyhow, Americans\Japanese will want to change this.
@@ -6081,6 +6081,11 @@ in | |||
|
|||
hyenae = callPackage ../tools/networking/hyenae { }; | |||
|
|||
hylafaxp = callPackage ../servers/hylafaxp { | |||
pam = null; | |||
openldap = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if those dependencies are never used in hylafax
, could we not drop them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since ldap and pam aren't useful to me I nulled them out.
But, a more enterprise-centric person might want to look at the module for hfaxd's inetd support that's likely to go with pam. Similarly, ldap...
${if (config.services.hylafaxp.config != "") then "cat ${_config} - > /var/spool/hylafax/etc/config" else ""} | ||
${if (config.services.hylafaxp.hfaxd.hosts != "") then "cat ${_hosts_hfaxd} - > /var/spool/hylafax/etc/hosts.hfaxd" else ""} | ||
${if (config.services.hylafaxp.faxDispatch != "") then "cat ${_FaxDispatch} - > /var/spool/hylafax/etc/FaxDispatch" else ""} | ||
${pkgs.ghostscript}/bin/gs -q -sDEVICE=tiffg3 -sFONTPATH="${pkgs.ghostscript}/share/ghostscript/fonts ${pkgs.ghostscript}/share/ghostscript/${pkgs.ghostscript.version}/Resource/Init ${pkgs.ghostscript}/share/ghostscript/${pkgs.ghostscript.version}/lib ${pkgs.ghostscript}/share/ghostscript/${pkgs.ghostscript.version}/Resource/Font ${pkgs.ghostscript}/share/ghostscript/fonts ${pkgs.ghostscript}/share/fonts/default/ghostscript ${pkgs.ghostscript}/share/fonts/default/Type1 ${pkgs.ghostscript}/share/fonts/default/TrueType" /var/spool/hylafax/bin/genfontmap.ps > /var/spool/hylafax/etc/Fontmap.HylaFAX 2>/dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can those files above replaced by writeText
and symlinks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need ghostscript to produce font names and paths depending on what's available on the system and the specific ghostscript package version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 maybe replacing FONTPATH with a nix variable will help a little?
assert dev != ""; | ||
nameValuePair "hylafaxp-faxgetty-${dev}" { | ||
description = "faxgetty ${dev}: HylaFAX+ front-door process"; | ||
after = optionals (dev!="dummy") [ "hylafaxp-setup.service" "hylafaxp-faxq.service" "${dev}.device" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mic92 This one sucks but I'm not sure how to clean it up.
I'd like to condition this entire let..in.. construct by config.services.hylafaxp.devs and move the error message** to the setupscript.
It's quite ugly and convoluted in an already complex structure but I don't know how to do the condition so I ended up recycling the unit to display the error so the unit won't be a total waste.
Similarly, there are also a few setupScript config.services.hylafaxp.devs if statements I'm not particularly happy about.
** letting the user know they should run faxsetup and update config.services.hylafaxp.devs accordingly
@Mic92 I've cleaned up a few problem spots including the FONTPATH you've requested. It's still being produced by ghostscript since we still need to account for different fonts and changes between ghostscript versions... But it's nicer looking :) @lethalman Thanks for explaining how to condition the let...in... statement. |
@RamKromberg |
@Mic92 Have you ever pushed the refactored version to mainline |
@7c6f434c no |
@Mic92 any reason not to push it (and close this PR afterwards)? |
@7c6f434c If memory serves, it was suggested the package should probably be rewritten (and updated*) to run in a container since it handles its own ring0->ring3 de-escalation. I think I tried doing it myself but run into some issues... Well, I was pretty satisfied with the C code security-wise and was running it for a few months without any major problems so I just never got around to doing it. Eventually, it stalled as I became "distracted" with unrelated low-level work and generally gone inactive with NixOS development. Seeing how I moved my fax-modem to a RasPi and been running Debian there... Well, it would be a shame to see so much work going to waste but I'll understand if you'd want to close the pull request. Though I wish it could be archived or something in case someone ends up wanting to work on it or something. |
@RamKromberg I think the refactored version by @Mic92 addresses some of the discussion. I asked about closing the PR after merging whatever further work on top of this PR has been done. In general, closed PRs are visible in a separate tab and are displayed in search; availability of the branch actually depends on whether you keep it in your fork. |
Closing this since #44496 was merged and now provides fax-sending from NixOS. Thanks @RamKromberg for laying the groundwork on this. |
Motivation for this change
trees?
Things done
Receiving and sending faxes works.
Email redirection works.
Optional hfaxd client-server service works (mostly for LAN clients) and some local GUIs.
Configuration is somewhat manual\interactive due to the nature of the hardware:
services.hylafaxp.enable = true;
This will produce persistent results between reboot & updates.
to services.hylafaxp and
to services.hylafaxp should be sufficient for local access. See faxadduser for LAN clients and passwords.
I've only tested one soft-modem, but I wrote the module to support multiple modems.
Built and tested with
nixos-rebuild switch -I nixpkgs=/home/user/nixpkgs
.(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)Note: HylaFAX vs. HylaFAX+ is 2012 vs. 2016.