我正在尝试设置:
networking.firewall.allowedTCPPortRanges = [ 80 81 5900];
但是我收到以下错误:
错误:选项值
networking.firewall.allowedTCPPortRanges.[definition 1-entry 1]' in
/etc/nixos/configuration.nix' 不是“有符号整数的属性集”类型。
networking.firewall.allowedTCPPorts = mkOption {
default = [];
example = [ 22 80 ];
type = types.listOf types.int;
description =
''
List of TCP ports on which incoming connections are
accepted.
'';
};
我使用的语法有什么问题?
答案1
中有两个名称相似的属性networking.firewall
:
- 允许的TCP端口
- 允许的TCP端口范围
前者是一个列表,因此 的值[80 81 5900]
是可以接受的。但是,后者是一个定义如下的集合:
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.
'';
};