如何使用Nix用git/local包覆盖Haskell包? [英] How do I override a Haskell package with a git / local package with Nix?
问题描述
基本上我正在使用这个:
Essentially I'm using this:
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存储库或本地目录?
However there is an issue with the pandoc-include-code
failing to build, which seems to have since been fixed in the git repository. How can I override the package either to point to git repository or a local directory?
我是否会按照 https://nixos.org上的说明进行操作/nixos/nix-pills/nixpkgs-overriding-packages.html 还是由于使用nixpkgs.pkgs.haskell.packages.${compiler}.callPackage
函数而导致工作原理不同?
Would I follow the instructions at https://nixos.org/nixos/nix-pills/nixpkgs-overriding-packages.html or would this work differently due to using the nixpkgs.pkgs.haskell.packages.${compiler}.callPackage
function?
修改: 感谢@sara的回答,我现在有了:
Thanks to @sara's answer I now have:
{ 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) { }
所以我想现在是确定现在如何覆盖该依赖关系的问题.
So it I suppose now it's a matter of determining how to override that dependency now.
推荐答案
我将要覆盖的存储库克隆到pandoc-include-code/
中,然后:
I cloned the repository I wanted to override into pandoc-include-code/
and then:
{ 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存储库:
For referencing the git repository directly:
{ 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" (./.) {}
这篇关于如何使用Nix用git/local包覆盖Haskell包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!