gpt4 book ai didi

haskell - nixOS:如何从同一包、同一版本的两个实例之间的冲突中恢复

转载 作者:行者123 更新时间:2023-12-02 12:28:16 26 4
gpt4 key购买 nike

这是我的 nixos 版本:

$ nixos-version 
16.09pre85931.125ffff (Flounder)

这是我的 shell 脚本:

$ cat test.nix 
{ nixpkgs ? import <nixpkgs> {
}, compiler ? "ghc801" }:

let
inherit (nixpkgs) pkgs;
ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (ps: with ps; [
diagrams
diagrams-pgf
]);
in
pkgs.stdenv.mkDerivation {
name = "test";
buildInputs = with pkgs; [
ghc
];
shellHook = ''
eval $(egrep ^export ${ghc}/bin/ghc)
'';
}

问题就在这里。请注意,同一包的同一版本的两个实例之间存在冲突:

$ nix-shell --pure test.nix 
these derivations will be built:
/nix/store/r6080kvlvdb16c1frz8alnm14xjizkf5-ghc-8.0.1.drv
building path(s) ‘/nix/store/1129nds6xhq6hqawdd2s9z9n6va57jgl-ghc-8.0.1’
collision between `/nix/store/amdnmbd8p52d49bqmphv9f7ly7lf7pkk-active-0.2.0.10/share/doc/x86_64-linux-ghc-8.0.1/active-0.2.0.10/html/Data-Active.html' and `/nix/store/yniw6akz2ldimdlj9yq968ldaf4j18h1-active-0.2.0.10/share/doc/x86_64-linux-ghc-8.0.1/active-0.2.0.10/html/Data-Active.html'
builder for ‘/nix/store/r6080kvlvdb16c1frz8alnm14xjizkf5-ghc-8.0.1.drv’ failed with exit code 255
error: build of ‘/nix/store/r6080kvlvdb16c1frz8alnm14xjizkf5-ghc-8.0.1.drv’ failed
/run/current-system/sw/bin/nix-shell: failed to build all dependencies

我知道如果软件包有不同的版本,那么我可以这样做:

$ nix-env --set-flag priority 15 <package>-<version>

但是由于包名称和版本相同,我不知道该怎么办。

我该如何恢复?

最佳答案

当尝试在 nixpkgs commit 125ffff 重现您的问题时,我得到一个不同的错误。即:

src/System/Texrunner/Online.hs:45:1: warning: [-Wunused-imports]
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()
[3 of 3] Compiling System.Texrunner ( src/System/Texrunner.hs, dist/build/System/Texrunner.o )

src/System/Texrunner.hs:18:1: warning: [-Wunused-imports]
The import of ‘Control.Applicative’ is redundant
except perhaps to import instances from ‘Control.Applicative’
To import instances alone, use: import Control.Applicative()
Preprocessing test suite 'tests' for texrunner-0.0.1.1...
[1 of 2] Compiling Tex.PDF ( tests/Tex/PDF.hs, dist/build/tests/tests-tmp/Tex/PDF.dyn_o )
[2 of 2] Compiling Main ( tests/Tests.hs, dist/build/tests/tests-tmp/Main.dyn_o )

tests/Tests.hs:5:1: error:
Failed to load interface for ‘Tex.LogParse’
Use -v to see a list of the files searched for.
builder for ‘/nix/store/g3mwscrvwsr9zrr5h14d59w7nh06qmsw-texrunner-0.0.1.1.drv’ failed with exit code 1
cannot build derivation ‘/nix/store/9las78qbxqrlhakhdiqwc2jf7g6i5688-ghc-8.0.1.drv’: 1 dependencies couldn't be built
error: build of ‘/nix/store/9las78qbxqrlhakhdiqwc2jf7g6i5688-ghc-8.0.1.drv’ failed

这让我相信 <nixpkgs>指向您机器上的不同提交。上述问题已在提交7c7417处修复。 。截至提交 80224e (在撰写本文时为大师)这种变化仍然活跃。那时我可以重现您的错误。

问题似乎是 diagramsdiagrams-pgf ,作为单独的包,依赖于 optparse-applicative 的不同版本。包裹diagrams-pgf其整个范围被新版本覆盖,这意味着它还引入了不同版本的 diagrams和其他依赖项。这似乎导致了碰撞。

一个简单的修复方法应该是仅依赖 diagrams-pgf在你的 nix-shell 中。大多数图表将作为diagrams-pgf的依赖项被拉入。因此仍然可用。

{ nixpkgs ? import <nixpkgs> {
}, compiler ? "ghc801" }:

let
inherit (nixpkgs) pkgs;
ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (ps: with ps; [
diagrams-pgf # <--- HERE
]);
in
pkgs.stdenv.mkDerivation {
name = "test";
buildInputs = with pkgs; [
ghc
];
shellHook = ''
eval $(egrep ^export ${ghc}/bin/ghc)
'';
}

ghc --show-packages 确认:

$ ghc --show-packages | grep 'name: diagrams'
name: diagrams-lib
name: diagrams-solve
name: diagrams-core
name: diagrams-pgf

不幸的是,包裹diagrams-svg ,由 diagrams 拉入,无法使用新版本 optparse-applicative 进行构建。因此,目前无法构建同时具有 diagrams 的环境。和diagrams-pgf无需修补其中一些软件包。

如果您需要diagrams-contrib ,那么以下应该可以解决问题:

{ nixpkgs ? import ~/src/nixpkgs {}
, compiler ? "ghc801" }:

let
inherit (nixpkgs) pkgs;
ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (ps: with ps; [
(diagrams-contrib.overrideScope (self: super: {
optparse-applicative = self.optparse-applicative_0_13_0_0;
})) # <--- HERE
diagrams-pgf
]);
in
pkgs.stdenv.mkDerivation {
name = "test";
buildInputs = with pkgs; [
ghc
];
shellHook = ''
eval $(egrep ^export ${ghc}/bin/ghc)
'';
}

关于haskell - nixOS:如何从同一包、同一版本的两个实例之间的冲突中恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40122520/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com