-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
syncthing: Fix systemd service #52852
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
Conversation
@@ -120,9 +120,9 @@ in { | |||
allowedUDPPorts = [ 21027 ]; | |||
}; | |||
|
|||
systemd.packages = [ pkgs.syncthing ]; | |||
systemd.packages = [ pkgs.syncthing.out pkgs.syncthing.bin ]; |
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.
What's the problem if pkgs.syncthing.bin
isn't included here?
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.
Fair question, initially it was pkgs.syncthing
which meant pkgs.syncthing.bin
. This was a problem, since the bin
output does not have the systemd service files.
By using pkgs.syncthing.out
the reference to the binaries got lost, so I thought to include bin
as a systemd.package.
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.
Looked it up, systemd.packages
(as I thought) only uses $out/etc/systemd
of the packages, it only adds systemd units defined in them:
nixpkgs/nixos/modules/system/boot/systemd-lib.nix
Lines 150 to 152 in 830599d
# Symlink all units provided listed in systemd.packages. | |
for i in ${toString cfg.packages}; do | |
for fn in $i/etc/systemd/${type}/* $i/lib/systemd/${type}/*; do |
So there won't be any problems with removing that (and pkgs.syncthing.out = pkgs.syncthing
)
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.
So there won't be any problems with removing that (and
pkgs.syncthing.out = pkgs.syncthing
)
I am afraid this is not correct, from my tests it is more like pkgs.syncthing.bin = pkgs.syncthing
.
My impression is that buildGoPackage
in pkgs/development/go-modules/generic/default.nix
sets
outputs = args.outputs or [ "bin" "out" ];
so the first output ("bin") is picked when output is not defined (a.k.a. pkgs.syncthing
).
So, we have to explicitly declare the "out" output in the systemd.packages
and then again we are missing a reference to the other output, which contains binaries.
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.
Ohh, I didn't check, you're right. pkgs.syncthing.out
in systemd.packages
should be good then. The binaries aren't needed in systemd.packages
though, so that can be removed.
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.
ok, good thing I understood out
well.
Now, I agree that binaries are not needed in systemd.packages
, but if I leave syncthing.bin
out, then it is not referred anywhere else, so it is not installed. This is why I kept it.
Other approaches would be:
- To include bin in
environment.systemPackages
. - To include bin in
system.extraDependencies
as mentioned in motivation. - To move the systemd files to $bin as suggested by @Mic92.
Personally I find 2 the most elegant, but it is mentioned that this option is primarily used by the installation tests. In the end, I will follow @Mic92's suggestion.
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.
In what way does putting it in systemd.packages
make it get installed? It shouldn't. If by "install" you mean having it accessible in $PATH
, then environment.systemPackages
is what you want (and I suspect you do). In NixOS it doesn't make sense to "install" something just to have it be built. Either it's needed (and then you refer to it where you need it and it gets available like this), or it's not needed (so you don't refer to it and it won't be available). There's no notion of installing it just to have it installed.
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.
syncthing provides systemd user units not system-wide ones.
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.
Now you can use pkgs.syncthing
again. In future we should get rid of the pointless out
output of go packages. We had go source code there before, which also didn't made any sense. However migrating from $bin back to $out is a bigger refactoring challenge.
Can you move all outputs to |
@GrahamcOfBorg build syncthing |
status? |
f6a42b1
to
a142eb8
Compare
|
Oh, can you format your last commit message with the |
a142eb8
to
243062a
Compare
243062a
to
6642f3f
Compare
Amended and rebased once again :) |
Motivation for this change
On some systems I tend to run syncthing only as a user, e.g.:
I have noticed recently that the syncthing service was missing. It appears that due to a refactoring, the syncthing package has now multiple outputs (bin and out). This PR:
systemd.packages
(bin
to have the executables in /nix/store andout
to include properly the systemd files - the latter was the reason that the syncthing service was missing)I am still unsure whether to include syncthing.bin in
systemd.packages
, let me know if we can do it in another way, e.g. include it insystem.extraDependencies
.Pinging @Mic92 since he refactored the syncthing package to use
buildGoPackage
in 643fabf.Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)