我在 IRC 频道中问过这个问题,但我想我会在这里记录它以供我自己和其他人参考。
我有一个 shell.nix 文件需要很长时间才能构建,特别是它似乎正在构建一个HUnit
包。
我的 shell.nix 文件如下所示:
{
sources ? import ./nix/sources.nix
, compiler ? "ghc865" } :
let
niv = import sources.nixpkgs {
overlays = [
(_ : _ : { niv = import sources.niv {}; })
] ;
config = {};
};
pkgs = niv.pkgs;
myHaskellPackages = pkgs.haskell.packages.${compiler}.override {
};
in
myHaskellPackages.callCabal2nix "moscoviumorange" (./.) {}
并且源被固定到(使用 niv):
{
"niv": {
"branch": "master",
"description": "Easy dependency management for Nix projects",
"homepage": "https://github.com/nmattia/niv",
"owner": "nmattia",
"repo": "niv",
"rev": "88d6f20882b0422470acbcbf2d1b5f07e1d436f0",
"sha256": "0wkvz4drnglmmdrz8q1i1yr2fqizpf96k1wq2rlhd8l8x1522izq",
"type": "tarball",
"url": "https://github.com/nmattia/niv/archive/88d6f20882b0422470acbcbf2d1b5f07e1d436f0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-19.03",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs-channels",
"rev": "775fb69ed73e7cf6b7d3dd9853a60f40e8efc340",
"sha256": "1w068b0ydw4c26mcjiwlzdfqcdk3rrwmfx4hxzgfhfwcz2nmh3if",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs-channels/archive/775fb69ed73e7cf6b7d3dd9853a60f40e8efc340.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
当我假设它们应该在 nixpkg 的二进制缓存中时,为什么 nix 会构建一堆包?
例如 nix-shell 的输出包括:
building '/nix/store/7011izw8f2xyvhqadrhnmapddyz61f29-HUnit-1.6.0.0.drv'...
我们可以在 Hydra (for 19.03) 中搜索 HUnit 包:
https://hydra.nixos.org/eval/1552169?filter=HUnit&compare=1551557&full=#tabs-still-fail
根据上面
HUnit
的构建,会在二进制缓存中。我们确定正在构建的派生的存储路径:
我们可以将以下内容与 hydra 进行比较:https ://hydra.nixos.org/build/103222205#tabs-details
404 表示路径不在二进制缓存中。
答案原来是我指
ghc
的是ghc865
当 hydra 可能ghc864
默认构建时(对于 19.03)。以上答案来自
clever
IRC#nixos
频道,谢谢!