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

yggdrasil: init at 0.3.8 and add service module #63863

Closed
wants to merge 4 commits into from

Conversation

gazally
Copy link
Contributor

@gazally gazally commented Jun 27, 2019

Motivation for this change

Use an encrypted ipv6 overlay network.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • 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 nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

See also #63855 by @Lassulus, which has a different derivation for yggdrasil which also works with the service module. This is my first attempt to write a Go derivation so I'll be happy to rebase this pull request on #63855 if that is preferable.

@JohnAZoidberg
Copy link
Member

Make sure to use the email address that is linked to your GitHub account for the commits, then they're linked to your profile account.

pkgs/tools/networking/yggdrasil/default.nix Outdated Show resolved Hide resolved
pkgs/tools/networking/yggdrasil/default.nix Outdated Show resolved Hide resolved
homepage = "https://yggdrasil-network.github.io/";
license = licenses.lgpl3;
maintainers = with maintainers; [ gazally ];
platforms = platforms.linux;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
platforms = platforms.linux;

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've just force pushed a commit which I think addresses all your issues with the package. Please take a look. I'm still working on the service module.

@gazally
Copy link
Contributor Author

gazally commented Jul 5, 2019

I just pushed a new version which applies many of systemd's sandboxing features to the yggdrasil service. I've got this running on 4 computers in 2 locations including one Raspberry Pi (aarch64) and have verified that local multicast peering and remote peering both work.

@aanderse
Copy link
Member

aanderse commented Jul 7, 2019

Great work! Any chance for a NixOS test?

@gazally
Copy link
Contributor Author

gazally commented Jul 7, 2019

Any chance for a NixOS test?

I also think it's a good idea, so I'll find myself a Perl tutorial and see what I can do.

Also, I've decided that it would be better to have service.yggdrasil.config be a Nix attribute set, and then use builtins.toJSON to convert it into a config file for yggdrasil, so I'll be making that change as well unless anyone objects.

@gazally
Copy link
Contributor Author

gazally commented Jul 8, 2019

In this latest push, I have:

  • Added a test.
  • Made services.yggdrasil.config into a Nix attribute set.
  • Added a new option services.yggdrasil.denyDhcpcdInterfaces so dhcpcd broadcasts can be suppressed on TAP interfaces.
  • Added an assertion on config.networking.enableIPv6.

Copy link
Member

@arcnmx arcnmx left a comment

Choose a reason for hiding this comment

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

Nice! I'm looking forward to using this to replace my current ad-hoc package and module. Leaving a few comments aiming to avoid preStart where it's unnecessary and keep the paths used a bit less hard-coded, mostly just because I'm often interested in running multiple yggdrasil services at once.

pkgs/tools/networking/yggdrasil/default.nix Outdated Show resolved Hide resolved
-ldflags=
-X github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil.buildVersion=${version}
-X github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil.buildName=${pname}
-s -w
Copy link
Member

Choose a reason for hiding this comment

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

(I know nothing about the go build system but) Should these flags be something included in buildGoModule instead? nixpkgs typically produces stripped binaries (excluding the dontStrip and keepDebugInfo opt-outs) so unless those flags tend to cause widespread problems it may be worth just doing this for all go packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kalbasit I think this is a question for you.

I put those flags in ldflags to make it match what yggdrasil's build script does. I'm also a go build system newbie so I don't know if the way they have set up their build is unusual or not.

'';

serviceConfig = {
ExecStart = "${cfg.package}/bin/yggdrasil -useconffile /etc/yggdrasil.conf";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ExecStart = "${cfg.package}/bin/yggdrasil -useconffile /etc/yggdrasil.conf";
ExecStart = "${cfg.package}/bin/yggdrasil -useconffile \${RUNTIME_DIRECTORY}/yggdrasil.conf";

I think? Though this can just refer to the config path directly unless it needs to be merged by preStart.

networking.firewall.allowedUDPPorts = mkIf cfg.openMulticastPort [ 9001 ];

# Make yggdrasilctl available on the command line.
environment.systemPackages = [ cfg.package ];
Copy link
Member

Choose a reason for hiding this comment

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

Okay so this one's just a personal wish and probably too opinionated but it'd be neat if we could get this to produce multiple outputs somehow, considering only yggdrasilctl really needs to be in the environment. They could also just be two separate derivations sharing the same source, not sure what's typical/standard for nixpkgs...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One reason to have yggdrasil in the environment is that yggdrasil -genconf and yggdrasil -genconf -json are useful commands to have available when you are working on your yggdrasil configuration.

Copy link
Member

Choose a reason for hiding this comment

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

Yup that's the main reason to run it from outside of the service, though that seems more what nix run nixpkgs.yggdrasil is for rather than making a one-time command a permanent part of the user environment - also ideally the nixos module documents all the settings so you wouldn't even have to do that!

@Lassulus
Copy link
Member

so whats the state of this? should we merge this now and work on the multiple instance stuff later? or does someone wants to implement it now?

@aanderse
Copy link
Member

Would the multiple instance stuff cause breaking api changes?

@arcnmx
Copy link
Member

arcnmx commented Aug 12, 2019

I wouldn't bother treating my comments as anything other than discussion points; I'm particularly interested due to how I use yggdrasil but that's not really relevant - and I can of course always continue to use a stripped-down module. The main areas I pointed out were paths that were a bit strangely hard-coded or inefficient/unnecessary, but I don't have a good understanding of nixos conventions or style regarding whether any of that actually matters (e.g. is polluting /etc bad or do plenty of other modules do it too?)

Also, what was the reason for meta.platforms being removed?

@gazally
Copy link
Contributor Author

gazally commented Aug 12, 2019

Upstream released 0.3.6 last week and I am hoping to find time this week to update the package.

I don't have a good understanding of nixos conventions or style regarding whether any of that actually matters (e.g. is polluting /etc bad or do plenty of other modules do it too?)

I'm in the same boat. I observed that other NixOS modules put things in /etc and did so too.

Also, what was the reason for meta.platforms being removed?

That was an accident. Thanks for catching it.

@gazally
Copy link
Contributor Author

gazally commented Aug 15, 2019

yggdrasil 0.3.5 and 0.3.6 now do not build due to a broken dependency, and upstream has marked it wontfix. They're recommending use of their develop branch or waiting for 0.3.7. Before that happened I was running into #64346 while trying to test the package on my mix of machines running 19.03 and unstable, so I guess I'll wait a bit.

@gazally gazally changed the title yggdrasil: init at 0.3.5 and add service module yggdrasil: init at 0.3.8 and add service module Sep 22, 2019
@gazally
Copy link
Contributor Author

gazally commented Sep 22, 2019

I've just pushed an update of the package to the latest version, 0.3.8. There is now an additional commit which removes DynamicUser from the service module. Yggdrasil works with DynamicUser set on systemd 242, but fails to open its network adapter if DynamicUser is set on systemd 243, and systemd 243 is now in Nixpkgs unstable. I have reported this issue to yggdrasil upstream.

@gazally
Copy link
Contributor Author

gazally commented Sep 23, 2019

yggdrasil 0.3.8 does not build on Go 1.13, which is pull request #68135. This will be fixed in yggdrasil 0.3.9.

@Lassulus
Copy link
Member

soo, I guess we can merge this now and fix the building on go1.13 later?

@arcnmx
Copy link
Member

arcnmx commented Oct 16, 2019

yggdrasil 0.3.10 is available now, and presumably includes the go 1.13 fix.

@ehmry ehmry self-assigned this Oct 26, 2019
@@ -2350,6 +2350,11 @@
github = "gavinrogers";
name = "Gavin Rogers";
};
gazally = {
Copy link
Member

Choose a reason for hiding this comment

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

You need to add your github id to this as part of recent requirements.

@ehmry
Copy link
Contributor

ehmry commented Oct 26, 2019

Merged to master, but githubId is still missing.

@ehmry ehmry closed this Oct 26, 2019
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

7 participants