如何在nix派生中克隆私有git存储库

克里斯·斯特里钦斯基(Chris Stryczynski)
{
  nixpkgs ? import <nixpkgs> {}
}:nixpkgs.pkgs.fetchgitPrivate {
        url = "ssh://[email protected]/trycatchchris/blog.git";
        rev = "0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716";
        sha256 = "02951e82c1183aaf1ce4b9669bf9ae32e50c4c641550797eed37739cd4528b58";
      }

我有上面的nix表达式,其中仓库是一个私人的git仓库。

我确实可以通过我的用户的公用密钥访问此存储库。

如果我尝试常规的nix-build

nix-build
trace: Please set your nix-path such that ssh-config-file points to a file that will allow ssh to access private repositories. The builder will not be able to see any running ssh agent sessions unless ssh-auth-sock is also set in the nix-path.

Note that the config file and any keys it points to must be readable by the build user, which depending on your nix configuration means making it readable by the build-users-group, the user of the running nix-daemon, or the user calling the nix command which started the build. Similarly, if using an ssh agent ssh-auth-sock must point to a socket the build user can access.

You may need StrictHostKeyChecking=no in the config file. Since ssh will refuse to use a group-readable private key, if using build-users you will likely want to use something like IdentityFile /some/directory/%u/key and have a directory for each build user accessible to that user.

these derivations will be built:
  /nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv
building '/nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv'...
exporting ssh://[email protected]/trycatchchris/blog.git (rev 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716) into /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e
Initialized empty Git repository in /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e/.git/
Can't open user config file /var/lib/empty/config: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Can't open user config file /var/lib/empty/config: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Unable to checkout 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716 from ssh://[email protected]/trycatchchris/blog.git.
builder for '/nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv' failed with exit code 1
error: build of '/nix/store/hlnshdb0ckckih46cv66xj8pyqds6w7y-blog-0f5fe7e.drv' failed

我已经尝试使用ssh代理以及(来自https://github.com/NixOS/nixpkgs/issues/4004#issuecomment-236434045):

创建ssh具有以下内容的文件:

Host gitlab.com
  StrictHostKeyChecking No
  UserKnownHostsFile /dev/null
  IdentityFile /home/chris/.ssh/id_rsa

并运行:

nix-build -I ssh-config-file=$PWD/ssh           
these derivations will be built:
  /nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv
building '/nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv'...
exporting ssh://[email protected]/trycatchchris/blog.git (rev 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716) into /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e
Initialized empty Git repository in /nix/store/mkinydhkdyg6dyw7fp399m90qw5bsbqd-blog-0f5fe7e/.git/
Can't open user config file /home/chris/temp/wiptemp/11/ssh: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Can't open user config file /home/chris/temp/wiptemp/11/ssh: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Unable to checkout 0f5fe7ebf0724eb17aea4141e0cf3f1758a6d716 from ssh://[email protected]/trycatchchris/blog.git.
builder for '/nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv' failed with exit code 1
error: build of '/nix/store/ng4qdayni3a69b57kfmrvf4ba03ryfv9-blog-0f5fe7e.drv' failed

但是,这也失败了。如何使用上述方法或其他方法克隆私有回购协议?

克里斯·斯特里钦斯基(Chris Stryczynski)
{
  nixpkgs ? import <nixpkgs> {}
}:(import (builtins.fetchGit {
        url = "ssh://[email protected]/trycatchchris/blog.git";
        rev = "4d127272689a5bc172e82529132b91e5943bb16f";
      }) {})

上面的(builtins.fetchGit)似乎可以完美运行,而无需设置沙箱等(使用默认的〜/ .ssh / id_rsa键)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

从Dockerfile克隆私有git存储库

来自分类Dev

如何在GitHub桌面应用程序中克隆私有BitBucket存储库

来自分类Dev

如何在Jenkins Job中克隆github组织的私有存储库

来自分类Dev

git在分叉私有存储库后无法克隆

来自分类Dev

git在分叉私有存储库后无法克隆

来自分类Dev

私有存储库的私有派生

来自分类Dev

如何使用初始化Shell脚本克隆私有Git存储库

来自分类Dev

如何使用初始化Shell脚本克隆私有Git存储库

来自分类Dev

如何克隆私有的GitLab存储库?

来自分类Dev

使GitLab CI克隆私有存储库

来自分类Dev

如何在具有 SSH 存储库访问权限的 AWS 私有 VPS 中安装 Phabricator

来自分类Dev

在git中的远程存储库上创建私有分支

来自分类Dev

如何将WordPress内容保存在私有git存储库中?

来自分类Dev

如何将WordPress内容保存在私有git存储库中?

来自分类Dev

克隆没有证书的私有github存储库?

来自分类Dev

如何在Swagger-UI上加载托管在私有GitHub存储库中的文件

来自分类Dev

如何在GitHub中为公共或私有存储库创建发布?

来自分类Dev

Git:如何在不将其与父存储库分离的情况下,在私有存储库中将子文件夹作为公共存储库?

来自分类Dev

可以从私有GitHub存储库中克隆和提取,但不能提取

来自分类Dev

如何在Thermal中克隆远程存储库?

来自分类Dev

使用脚本克隆私有Github存储库

来自分类Dev

如何在我的本地git克隆存储库之前判断github存储库是否

来自分类Dev

如何在我的本地git克隆存储库之前判断github存储库是否

来自分类Dev

如何从git存储库中删除文件,而不在克隆的存储库中删除文件

来自分类Dev

如何从git存储库中删除文件,而不在克隆的存储库中删除文件

来自分类Dev

如何克隆GIT存储库列表?

来自分类Dev

如何防止推送到Github中的私有存储库

来自分类Dev

如何在GIT中修补存储库

来自分类Dev

如何从git克隆存储库,但仍获得对原始存储库的更新?

Related 相关文章

  1. 1

    从Dockerfile克隆私有git存储库

  2. 2

    如何在GitHub桌面应用程序中克隆私有BitBucket存储库

  3. 3

    如何在Jenkins Job中克隆github组织的私有存储库

  4. 4

    git在分叉私有存储库后无法克隆

  5. 5

    git在分叉私有存储库后无法克隆

  6. 6

    私有存储库的私有派生

  7. 7

    如何使用初始化Shell脚本克隆私有Git存储库

  8. 8

    如何使用初始化Shell脚本克隆私有Git存储库

  9. 9

    如何克隆私有的GitLab存储库?

  10. 10

    使GitLab CI克隆私有存储库

  11. 11

    如何在具有 SSH 存储库访问权限的 AWS 私有 VPS 中安装 Phabricator

  12. 12

    在git中的远程存储库上创建私有分支

  13. 13

    如何将WordPress内容保存在私有git存储库中?

  14. 14

    如何将WordPress内容保存在私有git存储库中?

  15. 15

    克隆没有证书的私有github存储库?

  16. 16

    如何在Swagger-UI上加载托管在私有GitHub存储库中的文件

  17. 17

    如何在GitHub中为公共或私有存储库创建发布?

  18. 18

    Git:如何在不将其与父存储库分离的情况下,在私有存储库中将子文件夹作为公共存储库?

  19. 19

    可以从私有GitHub存储库中克隆和提取,但不能提取

  20. 20

    如何在Thermal中克隆远程存储库?

  21. 21

    使用脚本克隆私有Github存储库

  22. 22

    如何在我的本地git克隆存储库之前判断github存储库是否

  23. 23

    如何在我的本地git克隆存储库之前判断github存储库是否

  24. 24

    如何从git存储库中删除文件,而不在克隆的存储库中删除文件

  25. 25

    如何从git存储库中删除文件,而不在克隆的存储库中删除文件

  26. 26

    如何克隆GIT存储库列表?

  27. 27

    如何防止推送到Github中的私有存储库

  28. 28

    如何在GIT中修补存储库

  29. 29

    如何从git克隆存储库,但仍获得对原始存储库的更新?

热门标签

归档