From 36eac84f40aa938fd9327ddf4f983736ff550bcf Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 29 Dec 2020 22:29:57 -0500 Subject: Deploy hoogle to Biz.Dev I had to refactor Biz/Bild/Rules.nix. I also had to checkin my patched hoogle.nix file, but I also upstreamed the patch to nixpkgs-dev so it shouldn't stick around for too long. --- Biz/Bild/Rules.nix | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'Biz/Bild/Rules.nix') diff --git a/Biz/Bild/Rules.nix b/Biz/Bild/Rules.nix index f5f016f..9a7ad77 100644 --- a/Biz/Bild/Rules.nix +++ b/Biz/Bild/Rules.nix @@ -13,14 +13,14 @@ let lines = s: lib.strings.splitString "\n" s; removeNull = ls: builtins.filter (x: x != null) ls; - depsToPackageSet = packageSet: deps: + selectAttrs = deps: packageSet: lib.attrsets.attrVals deps packageSet; # returns true if a is a subset of b, where a and b are attrsets subset = a: b: builtins.all (x: builtins.elem x b) a; - haskellDeps = import ./Deps/Haskell.nix; + haskellDeps = hpkgs: import ./Deps/Haskell.nix hpkgs; # gather data needed for compiling by analyzing the main module analyze = main: rec { @@ -45,25 +45,20 @@ let (lines content))); }; - mkGhc = compiler: (deps: compiler (hp: - if (subset deps haskellDeps) - then depsToPackageSet hp deps - else throw '' - missing from nix/haskell-deps.nix: - ${toString (lib.lists.subtractLists haskellDeps deps)} - '')); - - ghc_ = mkGhc pkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; - ghcjs_ = mkGhc pkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; -in { + mkGhcPackageSet = pkgs.haskell.packages.${ghcCompiler}.ghcWithHoogle; + mkGhcjsPackageSet = pkgs.haskell.packages.${ghcjsCompiler}.ghcWithPackages; + +in rec { + ghcPackageSetFull = mkGhcPackageSet haskellDeps; + ghc = main: let data = analyze main; - ghc = ghc_ data.deps; + ghc = mkGhcPackageSet (hp: selectAttrs data.deps hp); in stdenv.mkDerivation { name = data.module; src = ../../.; - nativeBuildInputs = [ ghc ] ++ depsToPackageSet nixpkgs data.sysdeps; + nativeBuildInputs = [ ghc ] ++ selectAttrs data.sysdeps nixpkgs; strictDeps = true; buildPhase = '' mkdir -p $out/bin @@ -82,7 +77,7 @@ in { ghcjs = main: let data = analyze main; - ghcjs = ghcjs_ data.deps; + ghcjs = mkGhcjsPackageSet (hp: selectAttrs data.dep hp); in stdenv.mkDerivation { name = data.module; src = ../../.; @@ -108,9 +103,9 @@ in { name = "bizdev"; buildInputs = [ # haskell deps - (ghc_ haskellDeps) + (mkGhcPackageSet haskellDeps) # ghcjs doesn't need everything, and many things fail to build - (ghcjs_ [ + (mkGhcjsPackageSet [ "aeson" "clay" "containers" -- cgit v1.2.3