0

I'm trying to set:

  networking.firewall.allowedTCPPortRanges = [ 80 81 5900];

However I get the below error:

error: The option value networking.firewall.allowedTCPPortRanges.[definition 1-entry 1]' in /etc/nixos/configuration.nix' is not of type `attribute set of signed integers'.

It seems to be defined here https://github.com/NixOS/nixos/blob/5f444a4d8d49a497bcfabe2544bda264c845653e/modules/services/networking/firewall.nix#L118 as:

networking.firewall.allowedTCPPorts = mkOption {
  default = [];
  example = [ 22 80 ];
  type = types.listOf types.int;
  description =
    ''
      List of TCP ports on which incoming connections are
      accepted.
    '';
};

What is wrong with the syntax I'm using?

1

There are two similarly-named attributes in networking.firewall:

  • allowedTCPPorts
  • allowedTCPPortRanges

The former is a list, so a value of [80 81 5900] would be acceptable. But, the latter is a set defined as follows:

allowedTCPPortRanges = mkOption {
  type = types.listOf (types.attrsOf types.int);
  default = [ ];
  example = [ { from = 8999; to = 9003; } ];
  description =
    ''
      A range of TCP ports on which incoming connections are
      accepted.
    '';
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.