用分叉的Haskell软件包覆盖nixpkgs



我正在尝试用我自己的分支覆盖nixpkgs中的Haskell软件包。我拥有的代码似乎有效;我可以看到新的叉楼。但是,当我打开一个nix-shell时,我没有正确的软件包版本。

这是我shell.nix文件。

{
  nixpkgs ? import <nixpkgs> {
    config = {
      packageOverrides = super: let self = super.pkgs; in {
        haskellPackages = super.haskellPackages.override {
          overrides = self: super: {
            persistent = self.callPackage ../persistent/persistent/persistent.nix {};
          };
        };
      };
    };
  }
  , compiler ? "ghc822"
  , doBenchmark ? false
  , withHoogle ? true
}:
let
  inherit (nixpkgs) pkgs;
  f = { mkDerivation, aeson, base, base16-bytestring
      , base64-bytestring, blaze-html, bytestring, case-insensitive
      , classy-prelude, classy-prelude-conduit, classy-prelude-yesod
      , clientsession, conduit, containers, cryptohash, curl
      , data-default, directory, email-validate, errors, fast-logger
      , file-embed, foreign-store, hjsmin, hspec, http-client
      , http-client-tls, http-conduit, lens, mime-mail, mime-mail-ses
      , monad-control, monad-logger, persistent, persistent-postgresql
      , persistent-template, pwstore-fast, random, rollbar, safe
      , shakespeare, stdenv, template-haskell, text, time
      , unordered-containers, utf8-string, uuid, vector, wai, wai-extra
      , wai-logger, warp, yaml, yesod, yesod-auth, yesod-core, yesod-form
      , yesod-static, yesod-test
      }:
      mkDerivation {
        pname = "app";
        version = "0.0.0";
        src = ./.;
        isLibrary = true;
        isExecutable = true;
        enableSeparateDataOutput = true;
        buildDepends = [ pkgs.postgresql ];
        libraryHaskellDepends = [
          aeson base base16-bytestring base64-bytestring blaze-html
          bytestring case-insensitive classy-prelude classy-prelude-conduit
          classy-prelude-yesod clientsession conduit containers cryptohash
          curl data-default directory email-validate errors fast-logger
          file-embed foreign-store hjsmin http-client http-client-tls
          http-conduit lens mime-mail mime-mail-ses monad-control
          monad-logger persistent persistent-postgresql persistent-template
          pwstore-fast random rollbar safe shakespeare template-haskell text
          time unordered-containers utf8-string uuid vector wai wai-extra
          wai-logger warp yaml yesod yesod-auth yesod-core yesod-form
          yesod-static
        ];
        executableHaskellDepends = [
          aeson base bytestring case-insensitive classy-prelude
          classy-prelude-conduit classy-prelude-yesod conduit containers
          data-default directory fast-logger file-embed foreign-store hjsmin
          http-conduit monad-control monad-logger persistent
          persistent-postgresql persistent-template safe shakespeare
          template-haskell text time unordered-containers vector wai
          wai-extra wai-logger warp yaml yesod yesod-auth yesod-core
          yesod-form yesod-static
        ];
        testHaskellDepends = [
          aeson base bytestring case-insensitive classy-prelude
          classy-prelude-conduit classy-prelude-yesod conduit containers
          data-default directory fast-logger file-embed foreign-store hjsmin
          hspec http-conduit monad-control monad-logger persistent
          persistent-postgresql persistent-template safe shakespeare
          template-haskell text time unordered-containers uuid vector wai
          wai-extra wai-logger warp yaml yesod yesod-auth yesod-core
          yesod-form yesod-static yesod-test
        ];
        license = stdenv.lib.licenses.gpl3;
      };
  haskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};
  variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
  drv = variant (haskellPackages.callPackage f {});
in
  if pkgs.lib.inNixShell then drv.env else drv

我的持久分支中的版本号是 2.8.2 ,但是当我在 nix-shell 中运行 ghc-pkg list 时,我看到persistent-2.7.1。为什么?

我的叉子中的 nix 表达式如下所示:

{ mkDerivation, aeson, attoparsec, base, base64-bytestring
, blaze-html, blaze-markup, bytestring, conduit, containers
, fast-logger, haskell-src-meta, hspec, http-api-data
, monad-control, monad-logger, mtl, old-locale, path-pieces
, resource-pool, resourcet, scientific, silently, stdenv, tagged
, template-haskell, text, time, transformers, unliftio-core
, unordered-containers, vector, void
}:
mkDerivation {
  pname = "persistent";
  version = "2.8.2";
  src = ./.;
  libraryHaskellDepends = [
    aeson attoparsec base base64-bytestring blaze-html blaze-markup
    bytestring conduit containers fast-logger haskell-src-meta
    http-api-data monad-logger mtl old-locale path-pieces resource-pool
    resourcet scientific silently tagged template-haskell text time
    transformers unliftio-core unordered-containers vector void
  ];
  testHaskellDepends = [
    aeson attoparsec base base64-bytestring blaze-html bytestring
    conduit containers fast-logger hspec http-api-data monad-control
    monad-logger mtl old-locale path-pieces resource-pool resourcet
    scientific tagged template-haskell text time transformers
    unordered-containers vector
  ];
  homepage = "http://www.yesodweb.com/book/persistent";
  description = "Type-safe, multi-backend data serialization";
  license = stdenv.lib.licenses.mit;
}

我在 IRC 上得到了这个问题的回答。

我正在覆盖 haskellPackages,但是因为我将编译器设置为 ghc822 ,我实际上并没有使用被覆盖的包,因为这个条件:

haskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};

如果需要覆盖 haskell 包的源代码以便在nix-shell中运行其二进制文件,典型的overrideAttrs就足够了:

$ nix-shell -p 'git-annex.overrideAttrs (_: { src = builtins.filterSource (p: t: baseNameOf p != ".git") /path/to/git-annex-src; })'

我发布了这个答案,因为最初的问题没有清楚地说明覆盖意图是使用被覆盖的包作为依赖项(而不是简单地运行二进制文件(构建另一个应用程序。

相关内容

  • 没有找到相关文章

最新更新