我试图在Haskell开发环境中使用hoogle,就像奥查尔斯维基描述的那样
我已经像下面这样修改了shell.nix,以便使用hoogleLocal,但是它似乎没有为我安装hoogle二进制文件。
let
pkgs = import <nixpkgs> {};
# I'm attempting to use hoogle here, but it is not working.
haskellPackages =
let callPackage = pkgs.lib.callPackageWith haskellPackages;
in pkgs.recurseIntoAttrs (pkgs.haskellPackages.override {
extension = self: super: {
thiscurrentpackage = self.callPackage ./. {};
hoogleLocal = pkgs.haskellPackages.hoogleLocal.override {
packages = self.thiscurrentpackage;
};
};
});
in pkgs.myEnvFun {
name = haskellPackages.thiscurrentpackage.name;
buildInputs = [
(haskellPackages.ghcWithPackages (hs: ([
hs.cabalInstall
hs.ghcMod
hs.yesodBin
# This doesn't appear to install the hoogle binary?
hs.hoogleLocal
] ++ hs.thiscurrentpackage.propagatedNativeBuildInputs)))
];
}在生成的shell中,hoogle二进制文件不可用。
如果我将hs.hoogle包含到buildInputs中,则会安装hoogle二进制文件,但它无法找到数据库。下面是当我尝试使用它时会发生的事情。
$ nix-shell
......
$ hoogle Monad
Could not find some databases: default
Searching in:
.
/nix/store/91y9q2y5a2ws8xgcsx1gkhfagc0f2qz6-haskell-hoogle-ghc7.8.3-4.2.36-shared/share/x86_64-linux-ghc-7.8.3/hoogle-4.2.36/databases
There are no available databases, generate them with: hoogle data
$ hoogle data
hoogle: /nix/store/91y9q2y5a2ws8xgcsx1gkhfagc0f2qz6-haskell-hoogle-ghc7.8.3-4.2.36-shared/share/x86_64-linux-ghc-7.8.3/hoogle-4.2.36/databases:
changeWorkingDirectory: does not exist (No such file or directory)
$对于O‘’Charles所描述的设置,我如何使它正确工作?
编辑:原始shell.nix与这个答案中的相同。
发布于 2019-07-25 23:34:30
使用@Ben的答案作为参考,以下是我需要对cabal2nix --shell文件进行的必要更改的不同之处:
diff --git a/shell.nix b/shell.nix
index 540ade3..e207d6e 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,4 +1,4 @@
-{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
+{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false , withHoogle ? true}:
let
@@ -21,10 +21,23 @@ let
license = stdenv.lib.licenses.bsd3;
};
- haskellPackages = if compiler == "default"
+ haskellPackages' = if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
+ haskellPackages = (
+ if withHoogle
+ then haskellPackages'.override {
+ overrides = (self: super:
+ {
+ ghc = super.ghc // { withPackages = super.ghc.withHoogle; };
+ ghcWithPackages = self.ghc.withPackages;
+ }
+ );
+ }
+ else haskellPackages'
+ );
+
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
drv = variant (haskellPackages.callPackage f {});```https://stackoverflow.com/questions/27728838
复制相似问题