本质上,我使用的是:
default.nix
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc864" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./gitchapter.nix { }
gitchapter.nix
{ mkDerivation, base, directory, extra, filepath, foldl, hpack
, HUnit, mtl, optparse-applicative, pandoc-include-code, parsec
, pretty-simple, process, QuickCheck, rainbow, regex-pcre
, regex-posix, safe, stdenv, string-conversions, system-filepath
, template-haskell, text, transformers, turtle, unix
, unordered-containers
}:
mkDerivation {
pname = "gitchapter";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
libraryToolDepends = [ hpack ];
executableHaskellDepends = [
base directory extra filepath foldl HUnit mtl optparse-applicative
pandoc-include-code parsec pretty-simple process QuickCheck rainbow
regex-pcre regex-posix safe string-conversions system-filepath
template-haskell text transformers turtle unix unordered-containers
];
preConfigure = "hpack";
license = stdenv.lib.licenses.bsd3;
}
然而,有一个pandoc-include-code
无法构建的问题,这个问题似乎已经在git存储库中得到了修复。如何重写包以指向git存储库或本地目录?
我是否应该遵循https://nixos.org/nixos/nix-pills/nixpkgs-overriding-packages.html中的说明,或者使用nixpkgs.pkgs.haskell.packages.${compiler}.callPackage
函数会不会有不同的工作方式?
编辑:感谢@sara的回答,我现在有了:
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc864" } :
let
gitchapter = nixpkgs.pkgs.haskell.packages.${compiler}.callCabal2nix "gitchaper" (./.) {};
zzzzz = nixpkgs.pkgs.haskell.lib.overrideCabal gitchapter;
in
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage (zzzzz) { }
所以,我想现在是决定如何覆盖依赖的问题了。
发布于 2019-06-02 19:33:20
考虑使用haskell.packages.${compiler}
中的callCabal2nix
!
它将遍历您的.cabal文件并为从中派生的内容生成一个nix表达式(因此不需要gitchapter.nix ),然后您可以使用haskell.lib
中的overrideCabal
函数以类似于常规派生覆盖的方式覆盖该表达式。然后,您可以从git获取更新后的pandoc派生,并将其作为buildInput添加到覆盖表达式中。
发布于 2019-06-03 00:04:55
引用的本地路径示例:
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc864" } :
let
myHaskellPackages = nixpkgs.pkgs.haskell.packages.${compiler}.override {
overrides = self: super: rec {
pandoc-include-code = self.callCabal2nix "pandoc-include-code" (./pandoc-include-code) {};
};
};
in
myHaskellPackages.callCabal2nix "gitchaper" (./.) {}
其他替代方案:
Git存储库:
pandoc-include-code = self.callCabal2nix "pandoc-include-code" (builtins.fetchGit {
url = "git@github.com:owickstrom/pandoc-include-code.git";
rev = "3afe94299b3a473fda0c62fdfd318435117751dd";
})
{};
Hackage (通过tar归档)示例:
prettyprinter = self.callCabal2nix "prettyprinter" (builtins.fetchTarball {
url = "https://hackage.haskell.org/package/prettyprinter-1.7.0/prettyprinter-1.7.0.tar.gz";
}) {};
https://stackoverflow.com/questions/56414329
复制相似问题