1

我正在尝试用我自己的 fork 覆盖 nixpkgs 中的 Haskell 包。我的代码似乎有效;我可以看到新的分叉大楼。但是,当我打开 a 时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

我持久化的fork中的版本号是2.8.2,但是当我在其中运行ghc-pkg listnix-shell,我看到了persistent-2.7.1。这是为什么?

我的 fork 中的 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;
}
4

1 回答 1

0

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

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

haskellPackages = if compiler == "default"
                       then pkgs.haskellPackages
                       else pkgs.haskell.packages.${compiler};
于 2018-04-15T06:42:54.490 回答