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

Add port type #48687

Merged
merged 3 commits into from Nov 10, 2018
Merged

Add port type #48687

merged 3 commits into from Nov 10, 2018

Conversation

danielrutz
Copy link
Contributor

Motivation for this change

Many port values in nixos modules use types.int as a type. This allows invalid port numbers to be set. In theory, you could use types.ints.u16 instead, but types.port is more idiomatic. This change might lead to a wider usage of this type.

As an example, the sshd module has been changed to use the new type for the port.

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.

This change leads to an additional check of the port number at build time, making invalid port values impossible.
Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

I like that change and can imagine several places where this can be fairly useful.

But it would be great to have this properly documented as well, in nixos/doc/manual/development/option-types.xml you can add types.port. :)

@danielrutz
Copy link
Contributor Author

I have just added documentation for the type. Is it enough or should I write more about it?

Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

LGTM 👍
But I'd prefer to wait for at least another maintainer for confirmation :)

@infinisil
Copy link
Member

I'd like it to have this type be used on all options that use integer ports, can you do that?

@bobvanderlinden
Copy link
Member

👍

Have come across services that incorrectly set their port type to int. Using this type for all services will be harder to merge. I'd rather have this merged and have a separate PR (or PRs) to fix the types in the different services.

@infinisil infinisil merged commit e468a10 into NixOS:master Nov 10, 2018
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

6 participants