Error when using input in a flake

My flake is located here: dotfiles/flake.nix at 093b7ce354b0d2815a59c77bcbd5347d6b96a197 · refaelsh/dotfiles · GitHub.
Please look at line 14.
I am getting this error:

fatal: https://codeberg.org/xmobar/xmobar.git/?dir=nix/info/refs not valid: could not determine hash algorithm; is this a git repository?

This started happening all of a sudden. I did not change anything.

Help please :slight_smile:

What’s your nix (or lix) version?

Here is the output of nix --version:

~ nix --version
nix (Nix) 2.24.12

Amazing, seems like a nix bug! Report it at https://github.com/nixos/nix if no one else has.

$ nix repl
Lix 2.91.1
Type :? for help.
nix-repl> :lf git+https://codeberg.org/xmobar/xmobar.git/?dir=nix 
Added 17 variables.

$ nix shell nixpkgs#nix -c nix repl
Nix 2.24.12
Type :? for help.
nix-repl> :lf git+https://codeberg.org/xmobar/xmobar.git/?dir=nix
fatal: https://codeberg.org/xmobar/xmobar.git/?dir=nix/info/refs not valid: could not determine hash algorithm; is this a git repository?
warning: could not read HEAD ref from repo at 'https://codeberg.org/xmobar/xmobar.git/?dir=nix', using 'master'
fatal: https://codeberg.org/xmobar/xmobar.git/?dir=nix/info/refs not valid: could not determine hash algorithm; is this a git repository?

In the meantime, since lix appears to work, you could use that, or use an older version of nix.

1 Like

I am searching now throught open bugs in GitHub - NixOS/nix: Nix, the purely functional package manager, and this one looks like it maybe: Git fetcher: Don't create refs when fetching by revision by edolstra · Pull Request #12386 · NixOS/nix · GitHub. Or maybe this one: Environment variable GIT_DIR breaks builtins.fetchGit · Issue #12325 · NixOS/nix · GitHub? I am not sure.

I don’t think it’s #12325 because your issue surfaced in 2.24.12 only and isn’t present in 2.24.11, but #12325 is about 2.24.11 having some regressions. The other link is a PR, which doesn’t appear to fix your issue.

IMO you’d be better off reporting your issue, since I don’t see any open issue regarding the regression you found.

I’ve opened an issue here: Error Fetching xmobar Repository in Flake: Invalid Git Reference · Issue #12420 · NixOS/nix · GitHub.

1 Like

I’ve just got a reply on the issue I opened in Github, and it appears to be that a fix was checked a week a go. The questions is, how do I get it now? Since my nix is broken I cant update my system.

or use an older version of nix

Not so simple these days, as nixpkgs has removed every version of Nix before 2.24 (except 2.3). See the relevant issue.

In the absence of this, grabbing from stable is the best way to access versions like Nix 2.18 right now. Some things have improved since 2.18 that I’d like to keep, though, so Lix is my personal solution here.

cd my/flake/location
nix shell nixpkgs#lix
# rebuild, with Lix shadowing the system Nix version

It is, just choose an older commit that has an older version. Even 2.24.11 would suffice.

Lix also has implementation-specific bugs, so I wouldn’t necessarily recommend it as the only alternative here.

I didn’t test if nix 2.25 or 2.26 have this issue either, it’s possible they work too.

@waffle8946 I am not sure if I understand. Can you please tell me more?

nix shell github:nixos/nixpkgs/d114ef52edf12ffd5f661d6f261ccaeb6be6c261#nix

(temporarily) gets you a nix that can evaluate your config.
That’s only a workaround for now, if you don’t want to switch to lix.

1 Like

It worked! Thank you very much @waffle8946 :slight_smile: