Skip to main content

Nix value is not of type `attribute set of signed integers' [Resolved]

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?


Question Credit: Chris Stryczynski
Question Reference
Asked March 23, 2019
Tags: nixos
Posted Under: Unix Linux
16 views
1 Answers

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.
    '';
};

credit: Emmanuel Rosa
Answered March 23, 2019
Your Answer