基本上我在用这个:
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) { }
所以我想现在是确定现在如何覆盖该依赖关系的问题。
答案 0 :(得分:2)
考虑使用callCabal2nix
中的haskell.packages.${compiler}
!
它将遍历您的.cabal文件,并为该文件派生一个nix表达式(因此无需使用gitchapter.nix),然后您可以使用overrideCabal
中的haskell.lib
函数覆盖它与常规推导覆盖类似的方式。然后,您可以从git中获取更新的pandoc派生版本,并将其作为buildInput添加到您的覆盖表达式中。
答案 1 :(得分:1)
我将要覆盖的存储库克隆到pandoc-include-code/
中,然后:
{ 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存储库:
{ 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" (builtins.fetchGit {
url = "git@github.com:owickstrom/pandoc-include-code.git";
rev = "3afe94299b3a473fda0c62fdfd318435117751dd";
})
{};
};
};
in
myHaskellPackages.callCabal2nix "gitchaper" (./.) {}