Nix包管理器和GitLab的问题

问题描述 投票:1回答:1

我在OSX Mojave上使用Nix包管理器。

我的同事正在使用早期版本的OSX。不确定这是否是他们没有遇到这个问题的原因。

我无法连接到我明确有权访问的特定私有gitlab仓库。我可以直接克隆它,但是当我构建它所属的项目时,我无法构建它。

这是我的default.nix文件的相关摘录。我被告知fetchgitPrivate已被弃用。我试过在这个文件中用fetchGit替换它,但它不起作用。

      my-private-gitlab-repo = self.callCabal2nix "my-private-gitlab-repo" (pkgs.fetchgitPrivate {
        url = "[email protected]/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://[email protected]/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/
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[email protected]: 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://[email protected]/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密钥放在Shared和我的普通OSX用户中。我已经尝试了一百万个权限排列。

git gitlab devops nix
1个回答
1
投票

与Nix 2.x一起使用的正确选择是builtins.fetchGit - 但它不是直接替换:你需要删除sha256参数。因为builtins.fetchGit在您自己的用户帐户下运行,而不是作为Nix构建器运行,所以它完全可以解决权限问题:您可以自己访问的任何内容(密钥环,YubiKey或智能卡,或只是您的~/.ssh目录)可以通过副本访问git援引builtins.fetchGit

从而:

my-private-gitlab-repo = self.callCabal2nix "my-private-gitlab-repo" (builtins.fetchGit {
  url = "[email protected]/namehere/my-private-gitlab-repo.git";
  rev = "...";
}) {};
© www.soinside.com 2019 - 2024. All rights reserved.