Skip to content

flake-info does not pass pkgs argument to NixOS modules #902

Open
@2xsaiko

Description

@2xsaiko

As seen in #698 and #824. Modules such as https://git.sr.ht/~dblsaiko/nix-extras/tree/master/item/common/modules/programs/kakoune/default.nix fail eval with

error: attribute 'pkgs' missing

Notably, the errors in both packages come from usage of pkgs.formats.* in an option declaration (#824's is pkgs.formats.yaml). Might be that options types are inspected without evaluating config, specifically the NixOS module that exports the pkgs argument?

             … from call site
               at /nix/store/2pnmvlid82hrccm9qz4qxg8isjlw847n-source/common/modules/programs/kakoune/default.nix:13:10:
                 12|   cfg = config.programs.kakoune;
                 13|   toml = pkgs.formats.toml {};
                   |          ^
                 14| in {
      
             … while calling anonymous lambda
               at /nix/store/8rv7qar60c9p7hzwfa02syvl4yzrgmsm-source/lib/modules.nix:552:35:
                551|       context = name: ''while evaluating the module argument `${name}' in "${key}":'';
                552|       extraArgs = mapAttrs (name: _:
                   |                                   ^
                553|         addErrorContext (context name)
      
             … while evaluating the module argument `pkgs' in "/nix/store/2pnmvlid82hrccm9qz4qxg8isjlw847n-source/common/modules/programs/kakoune":
      
             error: attribute 'pkgs' missing
             at /nix/store/8rv7qar60c9p7hzwfa02syvl4yzrgmsm-source/lib/modules.nix:554:28:
                553|         addErrorContext (context name)
                554|           (args.${name} or config._module.args.${name})
                   |                            ^
                555|       ) (functionArgs f);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions