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

nncp: 7.7.0 -> 8.0.2, add NixOS module #146011

Closed
wants to merge 5 commits into from
Closed

nncp: 7.7.0 -> 8.0.2, add NixOS module #146011

wants to merge 5 commits into from

Conversation

ehmry
Copy link
Contributor

@ehmry ehmry commented Nov 14, 2021

Motivation for this change

The NNCP package is out of date and there is no NixOS module.

Some other things:

  • hjson doesn't work unless python is in PATH, fixed that
  • hjson is Python and therefore too slow to be called from an activation script, package hjson-go
  • Add a reference to the man page for systemd sockets to the listenStreams option description.
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
folkertdev Folkert de Vries
There already exists a package "hjson" but it's written in Python.
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python 8.has: module (update) This PR changes an existing module in `nixos/` labels Nov 14, 2021
@ehmry ehmry requested a review from woffs November 14, 2021 20:00
@dasJ dasJ removed their request for review November 14, 2021 20:02
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Nov 14, 2021
@ofborg ofborg bot requested a review from bhipple November 14, 2021 20:13
@woffs woffs mentioned this pull request Nov 15, 2021
@woffs
Copy link
Contributor

woffs commented Nov 15, 2021

Great work! My comments:

  • I do not get why a1dfbf6 belongs into this PR.
  • At my first try I get jq: error (at /nix/store/s9…nj-nncp.json:14): null (null) and object ({"self":{"e...) cannot be multiplied when merging my config in build, but the rebuild succeeds, with an empty /etc/nncp.hjson ­– maybe this should be handled more cleanly, or documented what to do and what not to do.
  • nixos test succeeds 👍

@ehmry
Copy link
Contributor Author

ehmry commented Nov 15, 2021

@woffs thanks. The configuration mangling and merging was working for me yesterday but now I'm getting similar errors. Maybe it breaks after a certain amount of neighbour complexity. Its a bit unusual that the conversion is happening in an activation script and not as part of a systemd unit, were an error might be more obvious. I think it needs to be thought out some more.

a1dfbf6 doesn't need to be part this PR, but found myself copy-pasting from documentation from the u9fs module when I should just look at the systemd socket options themselves.

Also, systemd is not passing everything that nncp-daemon expects, but the daemon still works in "pipe" mode.

@woffs
Copy link
Contributor

woffs commented Nov 17, 2021

Maybe you want to change nccp to nncp in the topic :-)

@ehmry ehmry changed the title nccp: 7.7.0 -> 8.0.2, add NixOS module nncp: 7.7.0 -> 8.0.2, add NixOS module Nov 30, 2021
This update introduces an encrypted packet format that is
incompatible with releases older than 8.0.0.
Add a module that generates a global NNCP configuration and adds a
TCP synchronization service.
@ehmry
Copy link
Contributor Author

ehmry commented Nov 30, 2021

@woffs I tweaked the configuration generator and the error has gone away for me (and I fixed the topic, thanks).

@ehmry
Copy link
Contributor Author

ehmry commented Nov 30, 2021

I'm not sure what the "user" should be for the nncp-daemon. My thought was that if there is a spool directory that can be modified by both a service and normal users then a non-dynamic user is appropriate, but systemd complains that using nobody is unsafe (but using root is fine).

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

I left a few comments. I don't know anything about nncp, so I'm not sure if my comments hold any value or not... Please let me know if any clarification is required. Thanks!

Comment on lines +83 to +84
spool = mkDefault "/var/spool/nncp";
log = mkDefault "/var/spool/nncp/log";
Copy link
Member

Choose a reason for hiding this comment

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

Can we not user directories favoured by systemd instead? /var/lib/nncp and /var/log/nncp? This gives us a few benefits when integrating with systemd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a traditional spool directory and I would not move it. It would contradict the spirit of NNCP as a UUCP replacement as well as the documentation.

whether <literal>autotoss</literal> is enabled and which
commands are enabled for remote execution.
'';
default = "nobody";
Copy link
Member

Choose a reason for hiding this comment

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

As already mentioned nobody/nogroup shouldn't be used.

Comment on lines +17 to +23
group = mkOption {
type = types.str;
default = "nncp";
description = ''
UNIX group that users must be in to use <literal>nncp</literal>.
'';
};
Copy link
Member

Choose a reason for hiding this comment

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

Does this option make the module easier to use for the user or make the module more complicated to understand/maintain?

I would suggest that maybe just using nncp as a hard coded group might be better. If I'm incorrect (I don't know anything about nncp, so very possible!) then we should consider following the common pattern in NixOS and only provision the group if the sysadmin leaves the default value of nncp:

users.groups = optionalAttrs (programCfg.group == "nncp") {
  nncp = { };
}

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 would prefer to hardcode this group, but I would also like to allocate a uid:gid pair, this is a traditional unix style service and we still support those.

with lib;

let
statefulCfgFile = "/etc/nncp.secrets";
Copy link
Member

Choose a reason for hiding this comment

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

Whenever I see stateful and /etc I wonder if there is a different way to do things - a way that better represents nix philosophies.

Maybe we should create a secretsFile option with type = with types; nullOr path; which defaults to null. If the sysadmin provides a file then we use it, otherwise we generate our own and store it in a stateful directory, like /var/lib/nncp/config. If we pair this with LoadCredential I think we have a reasonable chance at running this service with DynamicUser = true;.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is complicated because /etc/nncp.hjson must contain private keys and configuration, but nodes can only connnect to each other when the public key is known. It may be better to use a configuration directory.

"f ${programCfg.settings.log} 0770 root ${programCfg.group}"
];

system.activationScripts.nncp = ''
Copy link
Member

Choose a reason for hiding this comment

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

With my above comments on adding a secretsFile I think we might be able to entirely avoid using an activation script here, which would be ideal.

@ehmry ehmry mentioned this pull request Dec 17, 2021
13 tasks
@ehmry
Copy link
Contributor Author

ehmry commented Dec 18, 2021

I think we have problems with configuring NNCP that should be dicussed upstream before releasing a NixOS module. Package update moved to #151071.

@ehmry ehmry closed this Dec 18, 2021
@ehmry ehmry mentioned this pull request Feb 26, 2022
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants