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

nixos/darkhttpd: module to enable darkhttpd #48036

Merged
merged 1 commit into from Aug 26, 2019

Conversation

peterhoeg
Copy link
Member

Motivation for this change

I've had this one sitting around for quite a while.

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 nox --run "nox-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)
  • Fits CONTRIBUTING.md.

@peterhoeg peterhoeg self-assigned this Oct 8, 2018
@Mic92 Mic92 changed the title nixos darkhttpd: module to enable darkhttpd nixos/darkhttpd: module to enable darkhttpd Oct 8, 2018
Copy link
Member

@lukateras lukateras left a 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 = [ "" ];
Copy link
Member

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 = [];?

Copy link
Member Author

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}";
Copy link
Member

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.

Copy link
Member Author

@peterhoeg peterhoeg Oct 14, 2018

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"?

Copy link
Member

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;
Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

6 bytes.... 🤦‍♂️

Copy link
Member

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.

Copy link
Member Author

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 " " ([
Copy link
Member

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" ];
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

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

Should be named extraArgs

@peterhoeg
Copy link
Member Author

@infinisil , you're good with the current state?


package = mkOption {
default = pkgs.darkhttpd;
type = package;
Copy link
Member

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.

Copy link
Member

@lukateras lukateras Oct 29, 2018

Choose a reason for hiding this comment

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

Also see #48289 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

@infinisil
Copy link
Member

Ping? Other than the thing mentioned above, this looks good to me

@mmahut
Copy link
Member

mmahut commented Aug 10, 2019

Are there any updates on this pull request, please?

@peterhoeg
Copy link
Member Author

@GrahamcOfBorg eval

@peterhoeg
Copy link
Member Author

@GrahamcOfBorg eval

@peterhoeg
Copy link
Member Author

I ripped out the package option as the jury is still out on that. The rest should be fine.

@peterhoeg peterhoeg merged commit a859d0c into NixOS:master Aug 26, 2019
@peterhoeg peterhoeg deleted the m/darkhttp branch August 26, 2019 12:38
@peterhoeg peterhoeg restored the m/darkhttp branch August 26, 2019 14:26
@peterhoeg peterhoeg deleted the m/darkhttp branch August 27, 2019 02:23
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = true;
ExecStart = "${cfg.package}/bin/darkhttpd ${args}";
Copy link
Member

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 :)

Copy link
Member Author

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.

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

5 participants