Skip to content

Relative git flake inputs git+file:relative/path #12281

Open
@roberth

Description

Is your feature request related to a problem?

    • Nix currently resolves git+file:relative/path according to the process working directory instead of the flake.nix base directory. This is unreliable. Evaluation should be invariant under the process working directory, or it would violate the ability to be used as a flake input, among other things.
    • fetchTree does not have a base directory argument (and no implicit argument either, because that'd also be bad)
  • Therefore fetchTree does not have the information to resolve relative paths.

Solution for Flakes users

Users will be able to use a relative path reference since Nix 2.26 and they can enable submodules declaratively, planned for release in 2.27

{
  # For Nix 2.27:
  inputs.self.submodules = true;
  # instead of: inputs.foo.url = "git+file://./my-submodule";
  inputs.foo.url = ./my-submodule;
}

For Nix 2.26, instead of inputs.self.submodules, use:

nix build .?submodules=true#my-package

Proposed solution (for fetchTree)

  • Disallow git relative path inputs in fetchTree
  • Either
    • Resolve git relative path inputs in call-flake.nix (with a primop that does it? - unclear if that's future proof enough for reproducibility)
    • add a baseDirectory argument to fetchTree

Alternative solution

Forbid altogether. This blocks some users:

Additional context


Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    bugfeatureFeature request or proposalfetchingNetworking with the outside (non-Nix) world, input lockingidea approvedThe given proposal has been discussed and approved by the Nix team. An implementation is welcome.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions