gpt4 book ai didi

haskell - 如何将 GitHub 中的 Haskell 包添加到我的 shell.nix 文件中?

转载 作者:行者123 更新时间:2023-12-03 19:17:59 25 4
gpt4 key购买 nike

所以我有一个 Haskell 项目,它有一个如下所示的 shell.nix:

{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
ghc = pkgs.haskellPackages.ghcWithPackages (ps: with ps; [
regex-compat lucid replace-attoparsec hspec cabal-install text-regex-replace optparse-generic lens-regex-pcre clay bytestring charsetdetect AhoCorasick
]);
in
pkgs.stdenv.mkDerivation {
name = "my-haskell-env";
buildInputs = [ ghc ];
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
}

但是 AhoCorasick 坏了,我需要从这里安装它的自定义版本:

https://github.com/stackbuilders/AhoCorasick

我怎么做?我想这是使用 pkgs.fetchFromGitHub 的东西,但我什至无法在 Nix 手册中找到相关文档。

编辑:这是我目前正在尝试的:
{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
myAhoCorasickSrc = pkgs.fetchFromGitHub {
owner = "stackbuilders";
repo = "AhoCorasick";
rev = "cbf76b78612c66e51eb02f24162ace49325c5d61";
sha256 = "0ci5rywh042yi4ild3i7kx09rmj5v5iswzsah47f8axj1kq5vlci";
};
myAhoCorasick = pkgs.haskellPackages.callCabal2nix myAhoCorasickSrc {};
ghc = pkgs.haskellPackages.ghcWithPackages (ps: with ps; [
regex-compat
lucid
replace-attoparsec
hspec
cabal-install
text-regex-replace
optparse-generic
lens-regex-pcre
clay
bytestring
charsetdetect
myAhoCorasick
]);
in
pkgs.stdenv.mkDerivation {
name = "my-haskell-env";
buildInputs = [ ghc ];
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
}

奇怪的是,它似乎只是返回了一个 shell ,但缺少包。我究竟做错了什么?

最佳答案

您需要将您的包裹编入 haskellPackages放:

{ nixpkgs ? import <nixpkgs> {} }:
let
inherit (nixpkgs) pkgs;
myAhoCorasickSrc = pkgs.fetchFromGitHub {
owner = "stackbuilders";
repo = "AhoCorasick";
rev = "cbf76b78612c66e51eb02f24162ace49325c5d61";
sha256 = "0ci5rywh042yi4ild3i7kx09rmj5v5iswzsah47f8axj1kq5vlci";
};

myHaskellPackages = pkgs.haskellPackages.override {
overrides = self: super: with pkgs.haskell.lib; {
AhoCorasick = super.callCabal2nix "AhoCorasick" myAhoCorasickSrc {};

clay = doJailbreak (unmarkBroken super.clay);

replace-attoparsec = super.callHackageDirect {
pkg = "replace-attoparsec";
ver = "1.2.0.0";
sha256 = "0vgvrcv1inf90s620f48ixikpb9rfffq0mc1fxg7ffi8c0sijc2n";
} {};
};
};

ghc = myHaskellPackages.ghcWithPackages (ps: with ps; [
regex-compat
lucid
replace-attoparsec
hspec
cabal-install
text-regex-replace
optparse-generic
lens-regex-pcre
clay
bytestring
charsetdetect
AhoCorasick
]);
in
pkgs.mkShell {
name = "my-haskell-env";
buildInputs = [ ghc ];
}

(此外, replace-attoparsec 没有出现在我的 nixpkgs 中,所以我不得不添加,并且 clay 被标记为已损坏,因为它的边界对于我的 nixpkgs 中的 hspec/ hspec-discover 来说太窄了。)

关于haskell - 如何将 GitHub 中的 Haskell 包添加到我的 shell.nix 文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60161518/

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