Skip to content
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

Hylafaxplus #44496

Merged
merged 4 commits into from Sep 11, 2018
Merged

Hylafaxplus #44496

merged 4 commits into from Sep 11, 2018

Conversation

Yarny0
Copy link
Contributor

@Yarny0 Yarny0 commented Aug 5, 2018

This pull requests contains three commits

  • add myself to the maintainers list (is that ok?)
  • add a package hylafaxplus
  • add a nixos module to configure the hylafax server service (including secondary tasks such as spool directory maintainance and cleanup)
Motivation for this change

Send and receive faxes with NixOS.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS: 18.03 & unstable
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/): NixOS 18.03
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

There is another Pull Request to that end: #19392 , involved parties: @RamKromberg , @Mic92


package = mkOption {
type = package;
default = pkgs.hylafaxplus;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the alternative package to hylafaxplus? Can you add an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be a good idea to leave room for HylaFAX (not +). I faintly recall that a couple of years ago I had to use the not-plus version as HylaFAX+ did some things that broke my workflows. However, I don't recall the exact reason.

Would it be better to remove this option? I could do that as I currently need the plus-version only, and others might use the overlays-mechanism of nixpkgs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add it, when there are other alternatives to hylafaxplus available in nixpkgs. Otherwise overriding the package with an overlay should be sufficient.


faxcron.enable.spoolInit = mkEnableOption ''
Purge old files from the spooling area with
`faxcron`
Copy link
Member

@Mic92 Mic92 Aug 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docbook equivalent, would be <literal>faxcron</literal>

example = "daily";
description = ''
Purge old files from the spooling area with
`faxcron` with the given frequency
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too.

example = "daily";
description = ''
Purge old files from the spooling area with
`faxcron` with the given frequency
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too.

Enable or suppress job archiving:
`false` (the default!) disables archiving completely,
`true` forces archiving of all jobs,
while `null` only enables archiving for jobs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too.

''${cfg.package}/spool/bin/faxqclean''
''-q "${cfg.spoolAreaPath}"''
''-v''
(optionalString (cfg.faxqclean.archiving!=false) ''-a'')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: optionalString (cfg.faxqclean.archiving) ''-a'' is a bit more idiomatic and common.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really in this case: archiving can also be set to null, which means that it will archive only jobs that are flagged for archiving. I fear that optionalString will misunderstand null as boolean value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make it a enum instead of boolean option? faxqclean.archiving = null; is not so self-explaining.

''-q "${cfg.spoolAreaPath}"''
''-v''
(optionalString (cfg.faxqclean.archiving!=false) ''-a'')
(optionalString (cfg.faxqclean.archiving==true) ''-A'')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

# for a couple of standard binaries in the `PATH` and
# hardcode their absolute paths in the new package.
buildInputs = [
coreutils # for `base64` command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can assume coreutils to be always present.

openldap # optional
pam # optional
];
postPatch = ''. "${postPatch}"'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can assume postPatch to to contain spaces, since the nix store does not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[I guess that's a "not"]
Is that certain? I recall reading somewhere that the directory of the nix store may be changed (at the price of a complete rebuild of all packages). I generally try to be on the safe side with spaces or other shell characters.

Copy link
Member

@Mic92 Mic92 Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, spaces in the nix path are not supported and would break in many places. We prefer simpler code instead. Even if we would fix it, there are still many build systems and scripts that do not follow this assumption and we cannot fix all of them.

@Yarny0
Copy link
Contributor Author

Yarny0 commented Aug 10, 2018

I've updated my branch / pull request. The new version should address all comments so far. I haven't used <literal> everywhere in the documentation strings, but also <filename> and others that I've found in other documentation strings in nixpkgs. I feels alright.

Thanks to @Mic92 so far for all suggestions! I hope I haven't missed any with the new version.

@Mic92
Copy link
Member

Mic92 commented Aug 17, 2018

When enabling hylafax (services.hylafax.enable = true) the service fails to start:

● hylafax-spool.service - HylaFAX spool area preparation
   Loaded: loaded (/nix/store/pcxnbf9qdn9w0fqrisfybpihy1c5z31z-unit-hylafax-spool.service/hylafax-spool.service; linked; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-08-17 14:32:05 BST; 4min 17s ago
     Docs: man:hylafax-server(4)
  Process: 1142 ExecStart=/nix/store/8x88gkskijziagzkxsvil5jgnl49qpd1-unit-script-hylafax-spool-start (code=exited, status=1/FAILURE)
 Main PID: 1142 (code=exited, status=1/FAILURE)

Aug 17 14:32:05 turingmachine systemd[1]: Starting HylaFAX spool area preparation...
Aug 17 14:32:05 turingmachine 8x88gkskijziagzkxsvil5jgnl49qpd1-unit-script-hylafax-spool-start[1142]: cp: cannot stat '/nix/store/f69a1iijx3nir4c08pcdzvq9aqdfsd6j-hylafax-config-modems/*': No such file or directory
Aug 17 14:32:05 turingmachine systemd[1]: hylafax-spool.service: Main process exited, code=exited, status=1/FAILURE
Aug 17 14:32:05 turingmachine systemd[1]: hylafax-spool.service: Failed with result 'exit-code'.
Aug 17 14:32:05 turingmachine systemd[1]: Failed to start HylaFAX spool area preparation.

Create the top-level packages attribute
'hylafaxplus' that builds HylaFAX+ .

Note:
The nobody uid and the nogroup gid
are hardcoded in the package.
The package build recipe file
contains options to modify these ids.
This commit adds the following
* the uucp user
* options for HylaFAX server to control startup and modems
* systemd services for HylaFAX server processes
  including faxgettys for modems
* systemd services to maintain the HylaFAX spool area,
  including cleanup with faxcron and faxqclean
* default configuration for all server processes
  for a minimal working configuration

Some notes:

* HylaFAX configuration cannot be initialized with faxsetup
  (as it would be common on other Linux distributions).
  The hylafaxplus package contains a template spool area.
* Modems are controlled by faxgetty.
  Send-only configuration (modems controlled by faxq)
  is not supported by this configuration setup.
* To enable the service, one or more modems must be defined with
  config.services.hylafax.modems .
* Sending mail *should* work:
  HylaFAX will use whatever is in
  config.services.mail.sendmailSetuidWrapper.program
  unless overridden with the sendmailPath option.
* The admin has to create a hosts.hfaxd file somewhere
  (e.g. in /etc) before enabling HylaFAX.
  This file controls access to the server (see hosts.hfaxd(5) ).
  Sadly, HylaFAX does not permit account-based access
  control as is accepts connections via TCP only.
* Active fax polling should work; I can't test it.
* Passive fax polling is not supported by HylaFAX.
* Pager transmissions (with sendpage) are disabled by default.
  I have never tested or used these.
* Incoming data/voice/"extern"al calls
  won't be handled by default.
  I have never tested or used these.
@Yarny0
Copy link
Contributor Author

Yarny0 commented Sep 8, 2018

When enabling hylafax (services.hylafax.enable = true) the service fails to start

Yes, one needs to define at least one modem. I'm wondering if it would be useful to permit starting HylaFAX without modems, but there is probably no use to this. With the latest version of the pull request, I added an assertion that complains about missing modems. Additionally, I added a note on the need to define modems in the description of the config.services.hylafax.modems option.

There is another option with a similar effect: config.services.hylafax.userAccessFile points to /etc/hosts.hfaxd by default. This file must exist and be accessible by the uucp user only. The admin may create it with a proper config.environment.etc."hosts.hfaxd" configuration. I added a corresponding note in the option description. I'm not sure if I can/should check this more thoroughly.

Finally, I changed the names of some supporting build scripts of the package to be more consistent.

@Mic92 Mic92 merged commit 1bdba70 into NixOS:master Sep 11, 2018
@c0bw3b c0bw3b mentioned this pull request Oct 8, 2018
7 tasks
@Yarny0 Yarny0 deleted the hylafaxplus branch April 6, 2019 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants