Nix値は「符号付き整数の属性セット」タイプではありません。

Nix値は「符号付き整数の属性セット」タイプではありません。

以下を設定しようとしています。

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

ただし、次のエラーが発生します。

エラー:オプション値 networking.firewall.allowedTCPPortRanges.[definition 1-entry 1]' in /etc/nixos/configuration.nix'は、「符号付き整数の属性セット」タイプではありません。

ここで定義されているようです。https://github.com/NixOS/nixos/blob/5f444a4d8d49a497bcfabe2544bda264c845653e/modules/services/networking/firewall.nix#L118ように:

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

次のような名前の2つの属性があります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.
    '';
};

おすすめ記事