From 161c0765ad0e40408aeef07c2db896d185e66522 Mon Sep 17 00:00:00 2001 From: Daniel Rutz Date: Thu, 18 Oct 2018 23:39:13 +0200 Subject: Add type port as an alias to u16 --- lib/types.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/types.nix b/lib/types.nix index ca6794e274c3..d1ece2402ad7 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -169,6 +169,9 @@ rec { # s32 = sign 32 4294967296; }; + # Alias of u16 for a port number + port = ints.u16; + float = mkOptionType rec { name = "float"; description = "floating point number"; -- cgit 1.4.1 From c98a7bf8f284f278da1d7af23705ba232125f507 Mon Sep 17 00:00:00 2001 From: Daniel Rutz Date: Thu, 18 Oct 2018 23:42:20 +0200 Subject: nixos/sshd: Use port type instead of int This change leads to an additional check of the port number at build time, making invalid port values impossible. --- nixos/modules/services/networking/ssh/sshd.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/ssh/sshd.nix b/nixos/modules/services/networking/ssh/sshd.nix index c16fbe8a52fa..5fab79f1b3d7 100644 --- a/nixos/modules/services/networking/ssh/sshd.nix +++ b/nixos/modules/services/networking/ssh/sshd.nix @@ -130,7 +130,7 @@ in }; ports = mkOption { - type = types.listOf types.int; + type = types.listOf types.port; default = [22]; description = '' Specifies on which ports the SSH daemon listens. -- cgit 1.4.1 From 0885a651694853e2a125ecda5a37c3fe5e1ea005 Mon Sep 17 00:00:00 2001 From: Daniel Rutz Date: Fri, 19 Oct 2018 12:20:48 +0200 Subject: nixos/doc: Add documentation for types.port type --- nixos/doc/manual/development/option-types.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nixos/doc/manual/development/option-types.xml b/nixos/doc/manual/development/option-types.xml index e6c9eae11a72..d993e47bc914 100644 --- a/nixos/doc/manual/development/option-types.xml +++ b/nixos/doc/manual/development/option-types.xml @@ -106,7 +106,7 @@ - + types.ints.{u8, u16, u32} @@ -131,6 +131,17 @@ + + + types.port + + + + A port number. This type is an alias to + types.ints.u16. + + + -- cgit 1.4.1