Merge pull request #36393 from ElvishJerricco/haskell-shell-for
Haskell: Added haskellPackages.shellFor
This commit is contained in:
commit
df6e6d91a8
@ -188,6 +188,52 @@ in package-set { inherit pkgs stdenv callPackage; } self // {
|
|||||||
};
|
};
|
||||||
in withPackages (packages ++ [ hoogle ]);
|
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 // {
|
ghc = ghc // {
|
||||||
withPackages = self.ghcWithPackages;
|
withPackages = self.ghcWithPackages;
|
||||||
withHoogle = self.ghcWithHoogle;
|
withHoogle = self.ghcWithHoogle;
|
||||||
|
Loading…
Reference in New Issue
Block a user