Flake commands do not work in sha256 git repos #619

Open
opened 2025-01-08 12:05:57 +00:00 by kuruczgy · 2 comments

Describe the bug

Flake commands do not work in sha256 git repos.

Steps To Reproduce

  1. Create a sha256 git repo (git init --object-format=sha256)
  2. Add flake.nix, run some flake command to generate flake.lock. This will still work since the bug only occurs with a clean working directory.
  3. Commit your flake files.
  4. Run some flake command (e.g. nix eval ...). You will get an error like this:
    error: hash 'ae3c3c3b9dd70146d51991f2c5b9cdb4af7e65104f07e8376ac70ab2807250b0' has wrong length for hash type 'sha1'

Expected behavior

Flakes should work with any object format supported by git.

nix --version output

nix (Lix, like Nix) 2.91.1

Additional context

I found this CppNix issue: https://github.com/NixOS/nix/issues/9980 , but it was said on Matrix that Lix does not use libgit2, so probably the issue is something different?

## Describe the bug Flake commands do not work in sha256 git repos. ## Steps To Reproduce 1. Create a sha256 git repo (`git init --object-format=sha256`) 2. Add `flake.nix`, run some flake command to generate `flake.lock`. This will still work since the bug only occurs with a clean working directory. 3. Commit your flake files. 4. Run some flake command (e.g. `nix eval ...`). You will get an error like this: `error: hash 'ae3c3c3b9dd70146d51991f2c5b9cdb4af7e65104f07e8376ac70ab2807250b0' has wrong length for hash type 'sha1'` ## Expected behavior Flakes should work with any object format supported by git. ## `nix --version` output `nix (Lix, like Nix) 2.91.1` ## Additional context I found this CppNix issue: https://github.com/NixOS/nix/issues/9980 , but it was said on Matrix that Lix does not use libgit2, so probably the issue is something different?
Author

Just checked, bug still present on main (3413ab5629).

Just checked, bug still present on `main` (3413ab56292f12ac03ee49270bcaf16038020cb3).

looks like it's still true on version nix (Lix, like Nix) 2.92.0
trying to use a SHA256 flake input results in:

fetching Git repository 'https://forgejo.spacetime.technology/arbel/nix-assets'fatal: mismatched algorithms: client sha1; server sha256
error:
       … while updating the lock file of flake 'git+file:///etc/nixos'while updating the flake input 'nix-assets'while fetching the input 'git+https://forgejo.spacetime.technology/arbel/nix-assets?shallow=1'

       error: program 'git' failed with exit code 128
looks like it's still true on version `nix (Lix, like Nix) 2.92.0` trying to use a SHA256 flake input results in: ```sh fetching Git repository 'https://forgejo.spacetime.technology/arbel/nix-assets'fatal: mismatched algorithms: client sha1; server sha256 error: … while updating the lock file of flake 'git+file:///etc/nixos' … while updating the flake input 'nix-assets' … while fetching the input 'git+https://forgejo.spacetime.technology/arbel/nix-assets?shallow=1' error: program 'git' failed with exit code 128 ```
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#619
No description provided.