Skip to content

Regression: Interpretation of unqualified absolute paths in flake inputs (git+file:// ⇒ path:) #13012

@FraGag

Description

@FraGag

Describe the bug

Prior to Nix 2.26.0, when a flake input was specified as an absolute local path without an explicit type and that path was a Git repository, Nix inferred the git+file:// prefix. Since 2.26.0, Nix instead infers the path: prefix. This contradicts the documentation.

Steps To Reproduce

Create a flake.nix with the following content:

{
  inputs.foo.url = "/data/git/nix-systems-default";
  outputs = { self, foo }: { };
}

Adjust the path to refer to a local Git repository with a flake.nix at the root. For this example, I'm using a local clone of https://github.com/nix-systems/default (just because that flake has no dependencies).

Run nix flake update in the flake referencing foo.

The output is the following:

warning: creating lock file '"/home/francis/tmp/nix-bug/flake.lock"': 
• Added input 'foo':
    'path:/data/git/nix-systems-default?lastModified=1744516600&narHash=sha256-slOg/FqXVk9yb9aa9khpwWM%2BYZP/Nc65m7wutOYJbaA%3D' (2025-04-13)

Expected behavior

$ nix run nixpkgs#nixVersions.nix_2_24 -- flake update
warning: creating lock file '/home/francis/tmp/nix-bug/flake.lock': 
• Added input 'foo':
    'git+file:///data/git/nix-systems-default?ref=refs/heads/main&rev=da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)

Workaround

The workaround is to specify the type explicitly, i.e.:

{
  inputs.foo.url = "git+file:///data/git/nix-systems-default";
  outputs = { self, foo }: { };
}

Metadata

nix-env (Nix) 2.28.1

Additional context

I traced the change in behavior back to #10089. The very first commit, b2be6fe, has the change.

$ nix run github:NixOS/nix/bbe780b1374264fd01b99a7467d66e91d03ece47 -- flake update
warning: creating lock file '/home/francis/tmp/nix-bug/flake.lock': 
• Added input 'foo':
    'git+file:///data/git/nix-systems-default?ref=refs/heads/main&rev=da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)
$ rm flake.lock 
$ nix run github:NixOS/nix/b2be6fed8600ee48c05cc9643c101d5eab4a5727 -- flake update
warning: creating lock file '/home/francis/tmp/nix-bug/flake.lock': 
• Added input 'foo':
    'path:/data/git/nix-systems-default?lastModified=1744516600&narHash=sha256-slOg/FqXVk9yb9aa9khpwWM%2BYZP/Nc65m7wutOYJbaA%3D' (2025-04-13)

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

Labels

bugidea approvedThe given proposal has been discussed and approved by the Nix team. An implementation is welcome.

Projects

Status

🏁 Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions