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/darkhttpd: module to enable darkhttpd #48036
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.
LGTM otherwise.
|
||
extraConfig = mkOption { | ||
type = listOf str; | ||
default = [ "" ]; |
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 that empty string necessary, would it work if I pass services.darkhttpd.extraConfig = [];
?
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.
You're right, should just be an empty list.
wantedBy = [ "multi-user.target" ]; | ||
serviceConfig = { | ||
DynamicUser = true; | ||
ExecStart = "${pkgs.darkhttpd}/bin/darkhttpd ${optionsToArgs}"; |
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 be nice to have cfg.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.
Do you realistically see the darkhttpd package being overridden? Or is it more of a "best practice pattern"?
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.
Probably more of a pattern.
|
||
port = mkOption { | ||
default = 80; | ||
type = 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.
Can use ints.u16
now
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.
Any particular reason other than shaving off 2 bytes?
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.
6 bytes.... 🤦♂️
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 only allows valid port values, as opposed to 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.
👍
let | ||
cfg = config.services.darkhttpd; | ||
|
||
optionsToArgs = concatStringsSep " " ([ |
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.
A little bikeshedding on the naming: optionsToArgs
would imply it taking an argument, but really it's just the value of the arguments, so I'd go for just args
instead.
serviceConfig = { | ||
DynamicUser = true; | ||
ExecStart = "${pkgs.darkhttpd}/bin/darkhttpd ${optionsToArgs}"; | ||
AmbientCapabilities = lib.mkIf (cfg.port < 1024) [ "CAP_NET_BIND_SERVICE" ]; |
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.
Neat, would probably be nice to have this automatically done in the systemd module at some point.
''; | ||
}; | ||
|
||
extraConfig = 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.
Should be named extraArgs
@infinisil , you're good with the current state? |
|
||
package = mkOption { | ||
default = pkgs.darkhttpd; | ||
type = 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.
I'd actually rather not have this option. In general, the package can already be overridden with overlays, whose only disadvantage is that you can't override the package only for this module, it always happens for the whole system. This can be a problem when you e.g. want to override pkgs.curl
, which has lots of dependents, so it would rebuild a whole lot, which doesn't apply to darkhttpd
.
Every option increases evaluation time, so I'd rather have this be used for options that allow you to do something you couldn't otherwise do.
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.
Also see #48289 (comment).
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.
Also #49228 (comment)
Ping? Other than the thing mentioned above, this looks good to me |
Are there any updates on this pull request, please? |
@GrahamcOfBorg eval |
@GrahamcOfBorg eval |
I ripped out the |
wantedBy = [ "multi-user.target" ]; | ||
serviceConfig = { | ||
DynamicUser = true; | ||
ExecStart = "${cfg.package}/bin/darkhttpd ${args}"; |
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 you remove the package
option, you also need to change 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.
I'll fix this and add a test.
Motivation for this change
I've had this one sitting around for quite a while.
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)