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
nixos/zeronet: init #44842
nixos/zeronet: init #44842
Conversation
cc @fgaz |
# Ensure folder exists or create it and permissions are correct | ||
mkdir -p ${escapeShellArg cfg.dataDir} ${escapeShellArg cfg.logDir} | ||
chmod 750 ${escapeShellArg cfg.dataDir} ${escapeShellArg cfg.logDir} | ||
chown -R zeronet:zeronet ${escapeShellArg cfg.dataDir} ${escapeShellArg cfg.logDir} |
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.
If on startup all files are chowned, static uid/gids in nixos/modules/misc/ids.nix
are not necessary.
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.
I'm confused, this was fine on my hydron and meguca nix expressions?
Is there something that zeronet does differently?
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.
Not every reviewer knows about everything. I think ids.nix should be avoided if possible, and apparently it's indeed not needed with this.
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.
It can now be removed in meguca
as well. Back then when the static numbers where allocated it did not chown everything as this was added later: 36ab899
As meguca
might have a large number of image files this could potentially slow down the startup, which why having a static uid/gid would be fine to avoid having to adapt ownership on service start.
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.
Wait, so then we do need static uid/gids for zeronet?
If I remember right, zeronet should, at least over time, store at least a few gigabytes, over a lot of files(?).
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.
Oh, I see what you mean now.
|
||
makeWrapper "$out/share/zeronet.py" "$out/bin/zeronet_service" \ | ||
--set PYTHONPATH "$PYTHONPATH" \ | ||
--set PATH ${python2Packages.python}/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.
I think you can just use the first wrapper. If you pass a second set of --log_dir
and --data_dir
, it will override the first.
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.
That's already defined in the conf this service generates.
Better for ease-of-use and less possible problems.
@Mic92 Does anything need to be changed still? |
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.
@infinisil All good? |
type = types.path; | ||
default = "/var/log/zeronet"; | ||
example = "/home/okina/zeronet/log"; | ||
description = "Path to the zeronet log directory."; |
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.
Is it not possible to make it use the systemd journal?
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 can do this with zeronet?
Is it just a matter of moving the default value to $whatever/systemd/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.
stdout/stderr should work automatically. If it's not possible to tell it to output like that, /proc/self/fd/{1,2} might work
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.
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.
Does not seems like it can at the moment. It also does not do log rotation.
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.
Is there anything we can do here, or should I mark this as resolved?
--set PYTHONPATH "$PYTHONPATH" \ | ||
--set PATH ${python2Packages.python}/bin \ | ||
--add-flags "--log_dir \$HOME/.local/share/zeronet/logs" \ | ||
--add-flags "--data_dir \$HOME/.local/share/zeronet" |
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.
I don't think this binary should have been wrapped like this in the first place. Nix packages shouldn't pass convenience arguments, that's up to the user. If anything I'd argue to remove these arguments for the main binary and not have the zeronet_service
wrapper, makes much more sense.
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.
Unfortunately, zeronet will not start without log_dir and data_dir set, so I think I understand why @fgaz made this a wrapper. Not sure about PYTHONPATH or PATH, though, but I remember having problems calling the .py directly without the wrapper.
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.
Nix packages don't need to provide a binary that runs without any arguments, they just need to provide the binary that gets distributed, optionally wrapped with some env vars to make it work under Nix. Passing the right arguments will be the job of either the user or some wrapper higher up.
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.
Okay, I'll see if I can't get rid of the wrappers altogether, but I may still have to wrap the PYTHONPATH and maaaaaybe the PATH. If log_dir and data_dir aren't a problem, then I can easily get rid of the zeronet_service wrapper too.
@infinisil Okay, that should do it. |
@infinisil Are we all good? |
Okay, ready for review. |
description = "zeronet"; | ||
after = [ "network.target" (optionalString cfg.tor "tor.service") ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
restartTriggers = [ zConfFile ]; |
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.
Ah, this isn't needed when you reference it in ExecStart already
@infinisil All good? |
Motivation for this change
Simple service for zeronet, adjusted the package itself to make things easier.
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)