如何将 GitHub 中的 Haskell 包添加到我的 shell.nix 文件中?
How can I add a Haskell package from GitHub to my shell.nix file?
所以我有一个 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)";
}
奇怪的是,好像只是return一个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
被标记为已损坏,因为它的范围对于 hspec
/ hspec-discover
在我的 nixpkgs 中。)
所以我有一个 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)";
}
奇怪的是,好像只是return一个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
被标记为已损坏,因为它的范围对于 hspec
/ hspec-discover
在我的 nixpkgs 中。)