diff options
author | Peter Simons <simons@cryp.to> | 2018-03-07 12:45:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 12:45:06 +0100 |
commit | df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7 (patch) | |
tree | 037081d79f8274b747a6c43aeea141a606ba3851 /pkgs/development | |
parent | b6a28336e5471d94468617b29f2b0d510c43dc0f (diff) | |
parent | 9adb4d25e6a20ea3b9ae54df1cb9086c676b7d4c (diff) | |
download | nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.tar nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.tar.gz nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.tar.bz2 nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.tar.lz nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.tar.xz nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.tar.zst nixlib-df6e6d91a809b952ee8cc10e6bd9e5de8b0acfd7.zip |
Merge pull request #36393 from ElvishJerricco/haskell-shell-for
Haskell: Added haskellPackages.shellFor
Diffstat (limited to 'pkgs/development')
-rw-r--r-- | pkgs/development/haskell-modules/make-package-set.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index 2a96c66dced5..c793c0e70860 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -188,6 +188,52 @@ in package-set { inherit pkgs stdenv callPackage; } self // { }; in withPackages (packages ++ [ hoogle ]); + # Returns a derivation whose environment contains a GHC with only + # the dependencies of packages listed in `packages`, not the + # packages themselves. Using nix-shell on this derivation will + # give you an environment suitable for developing the listed + # packages with an incremental tool like cabal-install. + # + # # default.nix + # with import <nixpkgs> {}; + # haskellPackages.extend (haskell.lib.packageSourceOverrides { + # frontend = ./frontend; + # backend = ./backend; + # common = ./common; + # }) + # + # # shell.nix + # (import ./.).shellFor { + # packages = p: [p.frontend p.backend p.common]; + # withHoogle = true; + # } + # + # -- cabal.project + # packages: + # frontend/ + # backend/ + # common/ + # + # bash$ nix-shell --run "cabal new-build all" + shellFor = { packages, withHoogle ? false, ... } @ args: + let + selected = packages self; + packageInputs = builtins.map (p: p.override { mkDerivation = haskellLib.extractBuildInputs p.compiler; }) selected; + haskellInputs = + builtins.filter + (input: pkgs.lib.all (p: input.outPath != p.outPath) selected) + (pkgs.lib.concatMap (p: p.haskellBuildInputs) packageInputs); + systemInputs = pkgs.lib.concatMap (p: p.systemBuildInputs) packageInputs; + withPackages = if withHoogle then self.ghcWithHoogle else self.ghcWithPackages; + mkDrvArgs = builtins.removeAttrs args ["packages" "withHoogle"]; + in pkgs.stdenv.mkDerivation (mkDrvArgs // { + name = "ghc-shell-for-packages"; + nativeBuildInputs = [(withPackages (_: haskellInputs))] ++ mkDrvArgs.nativeBuildInputs or []; + buildInputs = systemInputs ++ mkDrvArgs.buildInputs or []; + phases = ["installPhase"]; + installPhase = "echo $nativeBuildInputs $buildInputs > $out"; + }); + ghc = ghc // { withPackages = self.ghcWithPackages; withHoogle = self.ghcWithHoogle; |