Skip to content

Cannot access inputs.self.outPath in top level imports #148

Open
@Atry

Description

@Atry

Given

# flake.nix
{
  inputs.flake-parts.url = "github:hercules-ci/flake-parts";
  outputs = inputs@{ self, flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } ({inputs, ...}: {
      imports = [
        "${inputs.self.outPath}/my-module.nix"
      ];
    });
}
# my-module.nix
{
  flake.lib.myFunction = x: x;
}

When running

nix flake show

Got

error: infinite recursion encountered

Root cause

NixOS/nix#8300

Workaround

# flake.nix
{
  inputs.flake-parts.url = "github:hercules-ci/flake-parts";
  outputs = inputs@{ self, flake-parts, ... }:
    {
      inherit (
        flake-parts.lib.mkFlake { inherit inputs; } ({inputs, ...}: {
          imports = [
            "${inputs.self.outPath}/my-module.nix"
          ];
        })
      ) lib;
    };
}

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