nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.55k stars 77 forks source link

Suddenly getting `git@github.com: Permission denied (publickey).` #287

Closed cideM closed 3 years ago

cideM commented 3 years ago

I'm using flakes and

dotfiles (master↑1|+1) $ nix --version
nix (Nix) 3.0pre20200829_f156513

I have sources such as

    "neovim": {
        "branch": "master",
        "ref": "master",
        "repo": "ssh://git@github.com/neovim/neovim",
        "rev": "a260d5def363ca30f0473365ea514f2dedd0d0ba",
        "type": "git"
    },

in my dotfiles and suddenly they all fail to fetch with a Permission denied (publickey) error. I can fetch them just fine in a nix repl using exactly the same parameters and builtins.fetchGit. I can also git clone these repositories. It's just the sources coming from niv that suddenly break. I have no idea why or how to debug this.

dotfiles (master↑1|✔) $ niv --version
0.2.18

I'm getting these errors when running nixos-rebuild switch on my NixOS machine. I also use home-manager and in there I use various sources managed through niv.

The same sources work just fine on MacOS and Arch using home-manager and

dotfiles (master|+1) $ nix --version
nix (Nix) 2.3.7

Then again it used to work with flakes before and builtins.fetchGit does work outside of nixos-rebuild switch. Lastly, the error happens even if I don't use flakes, but still run nixos-rebuild switch

Here's the full output

dotfiles (master↑3|✔) $ sudo nixos-rebuild switch --flake . --keep-going -j1 --fallback
building the system configuration...
fetching Git repository 'ssh://git@github.com/neovim/neovim'git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
warning: could not update local clone of Git repository 'ssh://git@github.com/neovim/neovim'; continuing with the most recent version
fatal: not a tree object: a260d5def363ca30f0473365ea514f2dedd0d0ba
error: --- Error ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix
failed to open archive: source threw exception: error: --- Error ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- nix
program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)
cideM commented 3 years ago

Okay this is likely not an issue with niv. The same issue occurs if I replace a call to a sources.nix file with just builtins.fetchGit. I think this has to do with me running nix-repl under my actual user account and nixos-rebuild as sudo. https://stackoverflow.com/questions/55425523/problem-with-nix-package-manager-and-gitlab