summaryrefslogtreecommitdiff
path: root/Biz/Bild/Rules.nix
diff options
context:
space:
mode:
Diffstat (limited to 'Biz/Bild/Rules.nix')
-rw-r--r--Biz/Bild/Rules.nix31
1 files changed, 13 insertions, 18 deletions
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"