go2nix icon indicating copy to clipboard operation
go2nix copied to clipboard

nix-prefetch-git fails without NIX_REMOTE being set (nix 2.0)

Open Profpatsch opened this issue 6 years ago • 0 comments

When go2nix invokes nix-prefetch-git, it fails because nix can’t access the nix-daemon:

→ go2nix save
2018/04/10 17:56:06 Initialized empty Git repository in /tmp/git-checkout-tmp-2emNcsso/payment-processors/.git/
From file:///home/philip/.go/src/gitlab.techcultivation.org/sangha/payment-processors
 * branch            HEAD       -> FETCH_HEAD
Switched to a new branch 'fetchgit'
removing `.git'...
error: Nix database directory ‘/nix/var/nix/db’ is not writable: Permission denied
2018/04/10 17:56:06 Command /nix/store/sgzjh8gbvx2r9lsbzjycmi1n9gfgbn8a-nix-prefetch-git/bin/nix-prefetch-git [nix-prefetch-git --fetch-submodules file:///home/philip/.go/src/gitlab.techcultivation.org/sangha/payment-processors] failed: exit status 1

When I set NIX_REMOTE, it works:

→ env NIX_REMOTE=daemon go2nix save
→

This is quite strange, because nix 2.0 shouldn’t need a set NIX_REMOTE to work properly. Even stranger, when I run the failing nix-prefetch-git command directly in my shell, it works:

→ env | grep NIX
NIX_PROFILES=/run/current-system/sw /nix/var/nix/profiles/default /home/philip/.nix-profile /etc/profiles/per-user/philip
NIX_PATH=vuizvui=/home/philip/vuizvui:nixpkgs=/home/philip/nixpkgs:nixos-config=/nix/store/6dl6avhcagic7hyq8pd2a33xg153a7q1-katara-configuration.nix
NIX_USER_PROFILE_DIR=/nix/var/nix/profiles/per-user/philip
NIXPKGS_CONFIG=/etc/nix/nixpkgs-config.nix
NIX_GHC=/nix/store/7ki3psspnd8a5azy2yxliglsklgp322b-ghc-8.2.2-with-packages/bin/ghc
→ nix-prefetch-git --fetch-submodules file:///home/philip/.go/src/gitlab.techcultivation.org/sangha/payment-processors
Initialized empty Git repository in /tmp/git-checkout-tmp-iHjVchBE/payment-processors/.git/
… git stuff …
{
  "url": "file:///home/philip/.go/src/gitlab.techcultivation.org/sangha/payment-processors",
  "rev": "7f0adc67638e9b369519d85b9a59c776bd89ccc4",
  "date": "2018-03-12T10:58:19+01:00",
  "sha256": "149nqp1299llhb1xy0ljz6r3h77gxa9jyqzhx1hgkrghjlij1hzk",
  "fetchSubmodules": true
}

cc @aszlig

Profpatsch avatar Apr 10 '18 17:04 Profpatsch