Unverified Commit b2ba46d8 authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

treewide: prefer `types.ints` over `addCheck` expressions (#442243)

parents 996b5556 3c10ae2f
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -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";
      };
+3 −3
Original line number Diff line number Diff line
@@ -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.
+1 −1
Original line number Diff line number Diff line
@@ -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"}").
+2 −2
Original line number Diff line number Diff line
@@ -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
+2 −2
Original line number Diff line number Diff line
@@ -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"}`).