Skip to content

Flake inputs cannot be local shallow git repositories (regression from 2.19.3, bisected) #9820

@Qyriad

Description

@Qyriad

Describe the bug

Adding a git+file: input to a flake which refers to a repository which was cloned shallowly results in an error of the form:

error:
       … while updating the lock file of flake 'git+file:///path/to/flake'

       … while updating the flake input 'nixpkgs'

       … while fetching the input 'git+file:///tmp/nixpkgs?shallow=1'

       error: getting parent of Git commit '9fe5cee74762d8687c11151e2dfb88c77ac0b5d4': object not found - no match for id (2e7eed72914de2d0d4d38e4d545ca26702dba818)

In Nix 2.19.3 and before it works correctly.

Steps To Reproduce

  1. Shallow-clone a git repository, e.g. git clone https://github.com/NixOS/nixpkgs --depth=1 /tmp/nixpkgs.
  2. Make a flake that uses that repository as an input, with or without ?shallow=1, e.g.:
{
  inputs.nixpkgs.url = "git+file:///tmp/nixpkgs";
  outputs = { self, nixpkgs }: { };
}
  1. Run nix flake update in that flake directory

Expected behavior — Behavior on Nix 2.9.2:

The flake updates and locks successfully, outputting Added input 'nixpkgs': git+file:///tmp/nixpkgs?ref… (etc)

nix-env --version output
nix-env (Nix) 2.19.0pre20231031_ee36a44

Additional context

Bisect points to ee36a44 from #9240.

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions