From 3c811c4f71cb97a930bd532431c56fc8e3c75f9b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 12 Sep 2025 02:29:08 +0200 Subject: [PATCH 1/5] nixos/postgrey: prefer `types.ints` over `addCheck` --- nixos/modules/services/mail/postgrey.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/mail/postgrey.nix b/nixos/modules/services/mail/postgrey.nix index 53c54c15c5d0..463757fa8440 100644 --- a/nixos/modules/services/mail/postgrey.nix +++ b/nixos/modules/services/mail/postgrey.nix @@ -10,9 +10,6 @@ let cfg = config.services.postgrey; - natural = with types; addCheck int (x: x >= 0); - natural' = with types; addCheck int (x: x > 0); - socket = with types; addCheck (either (submodule unixSocket) (submodule inetSocket)) (x: x ? path || x ? port); @@ -127,17 +124,17 @@ in description = "Prepend header to greylisted mails; use %%t for seconds delayed due to greylisting, %%v for the version of postgrey, %%d for the date, and %%h for the host"; }; delay = mkOption { - type = natural; + type = ints.unsigned; default = 300; description = "Greylist for N seconds"; }; maxAge = mkOption { - type = natural; + type = ints.unsigned; default = 35; description = "Delete entries from whitelist if they haven't been seen for N days"; }; retryWindow = mkOption { - type = either str natural; + type = either str ints.unsigned; default = 2; example = "12h"; description = "Allow N days for the first retry. Use string with appended 'h' to specify time in hours"; @@ -148,12 +145,12 @@ in description = "Strip the last N bits from IP addresses, determined by IPv4CIDR and IPv6CIDR"; }; IPv4CIDR = mkOption { - type = natural; + type = ints.unsigned; default = 24; description = "Strip N bits from IPv4 addresses if lookupBySubnet is true"; }; IPv6CIDR = mkOption { - type = natural; + type = ints.unsigned; default = 64; description = "Strip N bits from IPv6 addresses if lookupBySubnet is true"; }; @@ -163,7 +160,7 @@ in description = "Store data using one-way hash functions (SHA1)"; }; autoWhitelist = mkOption { - type = nullOr natural'; + type = nullOr ints.positive; default = 5; description = "Whitelist clients after successful delivery of N messages"; }; From e74440f374b5867ce7a54552d470b03847853261 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 12 Sep 2025 02:30:30 +0200 Subject: [PATCH 2/5] nixos/monero: prefer `types.ints` over `addCheck` --- nixos/modules/services/networking/monero.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/networking/monero.nix b/nixos/modules/services/networking/monero.nix index 9da570bbb5e2..5c0388aee32a 100644 --- a/nixos/modules/services/networking/monero.nix +++ b/nixos/modules/services/networking/monero.nix @@ -107,7 +107,7 @@ in }; mining.threads = lib.mkOption { - type = lib.types.addCheck lib.types.int (x: x >= 0); + type = lib.types.ints.unsigned; default = 0; description = '' Number of threads used for mining. @@ -174,7 +174,7 @@ in }; limits.threads = lib.mkOption { - type = lib.types.addCheck lib.types.int (x: x >= 0); + type = lib.types.ints.unsigned; default = 0; description = '' Maximum number of threads used for a parallel job. @@ -183,7 +183,7 @@ in }; limits.syncSize = lib.mkOption { - type = lib.types.addCheck lib.types.int (x: x >= 0); + type = lib.types.ints.unsigned; default = 0; description = '' Maximum number of blocks to sync at once. From 85077ec2b1b73c3f938d235a835d0780850f3de6 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 12 Sep 2025 02:31:48 +0200 Subject: [PATCH 3/5] nixos/tayga: prefer `types.ints` over `addCheck` --- nixos/modules/services/networking/tayga.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/tayga.nix b/nixos/modules/services/networking/tayga.nix index 8a039aa75abf..7ed0cf51e561 100644 --- a/nixos/modules/services/networking/tayga.nix +++ b/nixos/modules/services/networking/tayga.nix @@ -42,7 +42,7 @@ let }; prefixLength = mkOption { - type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128)); + type = types.ints.between 0 (if v == 4 then 32 else 128); description = '' Subnet mask of the interface, specified as the number of bits in the prefix ("${if v == 4 then "24" else "64"}"). From 770a8a679892dafc4e10c53395723198ccbbcbb9 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 12 Sep 2025 02:32:56 +0200 Subject: [PATCH 4/5] nixos/tinc: prefer `types.ints` over `addCheck` --- nixos/modules/services/networking/tinc.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/tinc.nix b/nixos/modules/services/networking/tinc.nix index 709431026739..a26b2af96cd7 100644 --- a/nixos/modules/services/networking/tinc.nix +++ b/nixos/modules/services/networking/tinc.nix @@ -72,7 +72,7 @@ let }; prefixLength = mkOption { - type = with types; nullOr (addCheck int (n: n >= 0 && n <= 128)); + type = with types; nullOr (ints.between 0 128); default = null; description = '' The prefix length of the subnet. @@ -227,7 +227,7 @@ in debugLevel = mkOption { default = 0; - type = types.addCheck types.int (l: l >= 0 && l <= 5); + type = types.ints.between 0 5; description = '' The amount of debugging information to add to the log. 0 means little logging while 5 is the most logging. {command}`man tincd` for From 3c10ae2f669237e977b3955dda2d06b038d979f2 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Fri, 12 Sep 2025 02:37:50 +0200 Subject: [PATCH 5/5] nixos/networking: prefer `types.ints` over `addCheck` --- nixos/modules/tasks/network-interfaces.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix index 09b6cec4e7ea..4b7e788bc33b 100644 --- a/nixos/modules/tasks/network-interfaces.nix +++ b/nixos/modules/tasks/network-interfaces.nix @@ -82,7 +82,7 @@ let }; prefixLength = mkOption { - type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128)); + type = types.ints.between 0 (if v == 4 then 32 else 128); description = '' Subnet mask of the interface, specified as the number of bits in the prefix (`${if v == 4 then "24" else "64"}`). @@ -99,7 +99,7 @@ let }; prefixLength = mkOption { - type = types.addCheck types.int (n: n >= 0 && n <= (if v == 4 then 32 else 128)); + type = types.ints.between 0 (if v == 4 then 32 else 128); description = '' Subnet mask of the network, specified as the number of bits in the prefix (`${if v == 4 then "24" else "64"}`).