buildLocalCabal: allow cabalDrvArgs in buildLocalCabalWithArgs

allows to write neat expressions like (as we're still generating an
expression string):

```
{
  build = haskellPackages.buildLocalCabalWithArgs {
    inherit src name;
    cabalDrvArgs = {
      jailbreak = false;
      doCheck = false;
    };
  };
}
```

without resorting to weird kung-fu like darcs does:

```
darcs = haskellPackages.darcs.override {
  # A variant of the Darcs derivation that containts only the
  # executable and
  # thus has no dependencies on other Haskell packages.
  cabal = { mkDerivation = x: rec { final = haskellPackages.cabal.mkDerivation (self: (x final) // {
            isLibrary = false;
            configureFlags = "-f-library"; }); }.final;
          };
};
```

While here, move the `jailbreak = true;` as the default `cabalDrvArgs`
option.
This commit is contained in:
Vladimir Kirillov 2014-05-05 23:36:34 +03:00
parent f69be7d8af
commit 7eff825487

View File

@ -3088,7 +3088,7 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
cabal2nix = callPackage ../development/tools/haskell/cabal2nix {};
# Build a cabal package given a local .cabal file
buildLocalCabalWithArgs = { src, name, args ? {} }: let
buildLocalCabalWithArgs = { src, name, args ? {}, cabalDrvArgs ? { jailbreak = true; } }: let
cabalExpr = pkgs.stdenv.mkDerivation ({
name = "${name}.nix";
@ -3096,16 +3096,17 @@ let result = let callPackage = x : y : modifyPrio (newScope result.finalReturn x
${self.cabal2nix}/bin/cabal2nix ${src + "/${name}.cabal"} --sha256=FILTERME \
| grep -v FILTERME | sed \
-e 's/licenses.proprietary/licenses.unfree/' \
-e 's/{ cabal/{ cabal, cabalInstall, src/' \
-e 's/{ cabal/{ cabal, cabalInstall, cabalDrvArgs ? {}, src/' \
-e 's/cabal.mkDerivation (self: {/cabal.mkDerivation (self: cabalDrvArgs \/\/ {/' \
-e 's/buildDepends = \[/buildDepends = \[ cabalInstall/' \
-e 's/pname = \([^\n]*\)/pname = \1\n inherit src;\n jailbreak = true;/' > $out
-e 's/pname = \([^\n]*\)/pname = \1\n inherit src;\n/' > $out
'';
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
});
in callPackage cabalExpr ({ inherit src; } // args);
in callPackage cabalExpr ({ inherit src cabalDrvArgs; } // args);
buildLocalCabal = src: name: self.buildLocalCabalWithArgs { inherit src name; };