hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
699 stars 38 forks source link

Infinite recursion error when unknown option is set #193

Closed khaled closed 9 months ago

khaled commented 9 months ago

Setting a top level attribute for which there is no option defined yields an infinite recursion error.

Example:

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs?rev=8efd5d1e283604f75a808a20e6cde0ef313d07d4";
  inputs.flake-parts.url = "github:hercules-ci/flake-parts?rev=c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4";
  outputs = inputs @ {flake-parts, ...}:
    flake-parts.lib.mkFlake {inherit inputs;} {
      systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
      perSystem = {pkgs, ...}: {
        packages.default = pkgs.hello;
      };
      foo.bar = 10;  # set an unknown option
    };
}

Output:

$ nix build

error:
       … in the left operand of the update (//) operator

         at «string»:56:13:

           55|             # This is shadowed in the next //
           56|             // sourceInfo
             |             ^
           57|             // {

       … while evaluating the attribute 'config.flake'

         at /nix/store/r88zkfh22shcgj0c4zh9jj2q5r1z9wjn-source/lib/modules.nix:320:9:

          319|         options = checked options;
          320|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          321|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: infinite recursion encountered

       at «none»:0: (source not available)
roberth commented 9 months ago

Fixed in #192

• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/c9afaba3dfa4085dbd2ccb38dfade5141e33d9d4' (2023-10-03)
  → 'github:hercules-ci/flake-parts/25abf6caa8e0c30e1e755eb384fd230316985121' (2023-10-29)

$ nix flake check
warning: Git tree '/tmp/flake-parts-193' is dirty
error: The option `foo' does not exist. Definition values:
       - In `<unknown-file>':
           {
             bar = 10;
           }
(use '--show-trace' to show detailed location information)

I'm surprised to see <unknown-file> still, but the error is now relevant.

roberth commented 9 months ago

surprised to see <unknown-file> still

Fixed in #194

khaled commented 9 months ago

much appreciated @roberth!