我在 OSX Mojave 上使用 Nix 包管理器。
我的同事正在使用早期版本的 OSX。不确定这是否是他们没有遇到此问题的原因。
我无法连接到我明确有权访问的特定私有(private) gitlab 存储库。我可以直接克隆它,但当我构建它所属的项目时,我无法构建它。
这是我的 default.nix 文件的相关摘录。我被告知 fetchgitPrivate 已被弃用。我尝试在该文件中将其替换为 fetchGit,但不起作用。
my-private-gitlab-repo = self.callCabal2nix "my-private-gitlab-repo" (pkgs.fetchgitPrivate {
url = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6c1cfd2e6c1cfd2cac7c488c5c9cb" rel="noreferrer noopener nofollow">[email protected]</a>/namehere/my-private-gitlab-repo.git";
rev = "...";
sha256 = "...";
}) {};
这是我收到的错误:
reallymemorables-MacBook-Pro:localclone reallymemorable$ ./scripts/ghci-backend
building '/nix/store/kljskajsdljkdgfhj-cabal2nix-my-private-gitlab-repo.drv'...
exporting ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b2d5dbc6f2d5dbc6ded3d09cd1dddf" rel="noreferrer noopener nofollow">[email protected]</a>/namehere/my-private-gitlab-repo.git (rev kjsdjfksdjklfsjkldjfksjdfskldf) into /nix/store/kljskajsdljkdgfhj-cabal2nix-my-private-gitlab-repo-asddfs
Initialized empty Git repository in /nix/store/kljskajsdljkdgfhj-cabal2nix-my-private-gitlab-repo-asddfs/.git/
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f99e908db99e908d95989bd79a9694" rel="noreferrer noopener nofollow">[email protected]</a>: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="43242a3703242a372f22216d202c2e" rel="noreferrer noopener nofollow">[email protected]</a>: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Unable to checkout khjsdfkhdsjhklsdjhfksdhfjksdh from ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="65020c1125020c110904074b060a08" rel="noreferrer noopener nofollow">[email protected]</a>/namehere/my-private-gitlab-repo.git.
builder for '/nix/store/kljskajsdljkdgfhj-cabal2nix-my-private-gitlab-repo-asdffdsgfd.drv' failed with exit code 1
cannot build derivation '/nix/store/kljskajsdljkdgfhj-cabal2nix-my-private-gitlab-repo.drv': 1 dependencies couldn't be built
error: build of '/nix/store/kljskajsdljkdgfhj-cabal2nix-my-private-gitlab-repo.drv' failed
(use '--show-trace' to show detailed location information)
我完全不知道如何继续。我尝试将 ssh key 放入共享和普通 OSX 用户中。我已经尝试了一百万种权限排列。
最佳答案
与 Nix 2.x 一起使用的正确方法是 builtins.fetchGit
——但它不是直接替代:您需要删除 sha256
参数。因为builtins.fetchGit
在您自己的用户帐户下运行,而不是作为 Nix 构建者,所以它完全解决了权限问题:您可以自己访问的任何内容( key 环、YubiKey或智能卡,或者只是您的 ~/.ssh
目录)可以通过 builtins.fetchGit
调用的 git
副本进行访问。
因此:
my-private-gitlab-repo = self.callCabal2nix "my-private-gitlab-repo" (builtins.fetchGit {
url = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73141a0733141a071f12115d101c1e" rel="noreferrer noopener nofollow">[email protected]</a>/namehere/my-private-gitlab-repo.git";
rev = "...";
}) {};
关于git - Nix 包管理器和 GitLab 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55425523/