如何通过Nix在nixpkgs中覆盖Haskell软件包? [英] How do I override a Haskell package in nixpkgs via Nix?

查看:51
本文介绍了如何通过Nix在nixpkgs中覆盖Haskell软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我在用这个:

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.

推荐答案

考虑使用 haskell.packages.$ {compiler} 中的 callCabal2nix

它将遍历您的.cabal文件,并为该文件派生一个nix表达式(因此无需使用gitchapter.nix),然后可以使用中的 overrideCabal 函数覆盖该表达式haskell.lib 的方式类似于普通推导覆盖.然后,您可以从git获取更新的pandoc派生版本,并将其作为buildInput添加到您的覆盖表达式中.

It will go through your .cabal file and generate a nix expression for a derivation from that (thus making gitchapter.nix unnecessary), which you then can override using the overrideCabal function in haskell.lib in a similar fashion to normal derivation overriding. You can then fetch the updated pandoc derivation from git, and add it as a buildInput in your override expression.

这篇关于如何通过Nix在nixpkgs中覆盖Haskell软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆