-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Add lotide, hitide and service definitions for both #107505
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
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.
Thanks for the contribution. I have left some comments I hope that you will find helpful. If you need any clarification, etc... please don't hesitate to ask.
There are a few options to test this. You could use build-vm
, include these modules into your current system using overlays
and imports
, build your system against this branch, etc... In addition to any of these ways a NixOS test would be greatly appreciated. See the nixos/tests
folder for examples of NixOS tests. These tests give committers unfamiliar with the software greater confidence in merging updates to your packages in the future.
backendHost = mkOption { | ||
default = null; | ||
type = types.string; | ||
description = "URL path to lotide"; |
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.
Please consistently use a trailing period for all descriptions, except for those with mkEnableOption
.
|
||
port = mkOption { | ||
default = 4333; | ||
type = types.int; |
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.
types.port
please.
Environment = [ | ||
"BACKEND_HOST=${cfg.backendHost}" | ||
"PORT=${cfg.port}" | ||
]; |
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 prefer to use systemd.services.<name>.environment
here instead, like so:
systemd.services.hitide = {
environment = {
BACKEND_HOST = cfg.backendHost;
PORT = cfg.port;
};
};
options.services.hitide = { | ||
enable = mkEnableOption "the hitide service"; | ||
|
||
package = mkOption { |
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 is only one version of hitide
available, and there are no variants on it. This option provides no value, in my opinion.
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 disagree... I started contributing to lotide/hitide development and would like to run development versions of it on my server, where I overwrite the package to build from different sources. This option gives me the abiltity to easily deploy different versions.
I would like to keep it therefore.
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.
Sure, it is fine to keep... but it sounds like what you really want is an overlay 🤔
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.
After some more thinking, I guess you're right here.
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.hitide = { |
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.
Would you consider submitting a change upstream to include a systemd
unit in their repo? If so, we could eventually (mostly) drop the unit from nixpkgs an utilize systemd.packages = [ pkgs.hitide ];
. If you're up for that full bonus points will be awarded 🎉
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 sure whether they would accept such patches upstream, but I will see what I can do and then report back 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.
Fantastic! Thanks.
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.lotide = { |
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.
Would you consider submitting a change upstream to include a systemd
unit in their repo? If so, we could eventually (mostly) drop the unit from nixpkgs an utilize systemd.packages = [ pkgs.lotide ];
. If you're up for that full bonus points will be awarded 🎉
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.
Can you give some more detail on that? Does that mean that the lotide.service
or hitide.service
file from upstream can be included here? How can I point to the actual path in the upstream repository? How can I make them configurable from nix?
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.
Sure. If pkgs.lotide
any .service
files under $out/lib/systemd/system
and you specify systemd.packages = [ pkgs.lotide ];
then these systemd
unit files will be included in your system when built.
Checkout this commit where I made use of the upstream systemd
unit, but then provided a few changes on top of the upstream unit specifically for NixOS.
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 the package needs to install them properly, okay.
And there's no way for a user of the service definition to overwrite values in the definition?
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 so.
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.
Hm. After some more thinking about the whole thing, I guess it is not a good idea to include a .service file from upstream - because lotide/hitide is configured via environment variables... A user actually wants to overwrite the environment of the services. Having a .service file prevents that (from my understanding).
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.
Both NixOS and systemd
excel here. Both allow extensive overriding to handle situations like this, both from the perspective of the distro and the perspective of the sysadmin.
Here is a reasonable starting point to learn about this: https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service
Let me know if you have any questions.
Thanks for your suggestions, I will resolve them in the coming days. BTW: What did the github engineers think when they built the "Commit suggestion" feature? Why doesn't this create |
Okay, so I just pushed some fixups (for example I used the deprecated I tried to use nixos-shell with:
Edit: It errors with "expected set, got list" or something like that. But I do not know why. |
@matthiasbeyer apply this to fix: a5c9b67 |
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
0be90b2
to
8533f37
Compare
Add lotide, hitide and service definitions for both.
As I do not often write service definitions, please someone have a look at those.
I did not yet test them. I don't know how, tbh. Maybe by rebasing these patches to nixos-stable and then building my system from it? Isn't there a smoother way for that?
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)