From 72af3505b2882b090c833532eff9204a46004dcd Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 10 Apr 2020 14:46:45 -0700 Subject: Get the ghcjs build working --- biz.nix | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'biz.nix') diff --git a/biz.nix b/biz.nix index 6dc10d3..b6e59ce 100644 --- a/biz.nix +++ b/biz.nix @@ -34,16 +34,15 @@ in { ghc = pkgs.haskell.packages.ghc865.ghcWithHoogle (hp: if (subset deps allDeps) then depsToPackageSet hp deps - else throw ("missing from deps.nix: ${toString (lib.lists.subtractLists allDeps deps)}") - ); + else throw + "missing from deps.nix: ${toString (lib.lists.subtractLists allDeps deps)}"); in stdenv.mkDerivation { name = module; - version = "0"; src = ./.; nativeBuildInputs = [ ghc ]; strictDeps = true; buildPhase = '' - mkdir -p $out/{bin,static} ${baseNameOf relpath} + mkdir -p $out/bin # compile with ghc ${ghc}/bin/ghc -Werror -i. \ --make ${main} \ @@ -59,21 +58,24 @@ in { relpath = builtins.replaceStrings ["${root}/"] [""] (builtins.toString main); module = builtins.replaceStrings ["/" ".hs"] ["." ""] relpath; content = builtins.readFile main; - exe = builtins.head (lists.flatten (seq + exe = builtins.head (lists.flatten (removeNull (map (builtins.match "^-- : exe ([[:alnum:]._-]*)$") (lines content)))); - deps = lists.flatten (seq + deps = lists.flatten (removeNull (map (builtins.match "^-- : dep ([[:alnum:]._-]*)$") (lines content))); - ghcjs = ghcjs_.ghcWithPackages (hp: depsToPackageSet hp deps); + ghcjs = pkgs.haskell.packages.ghcjs.ghcWithPackages (hp: + if (subset deps allDeps) + then depsToPackageSet hp deps + else throw + "missing from deps.nix: ${toString (lib.lists.subtractLists allDeps deps)}"); in stdenv.mkDerivation { name = module; - version = "0"; src = ./.; nativeBuildInputs = [ ghcjs ]; strictDeps = true; buildPhase = '' - mkdir -p $out/{bin,static} ${baseNameOf relpath} + mkdir -p $out/static # compile with ghcjs ${ghcjs}/bin/ghcjs -Werror -i. \ --make ${main} \ @@ -81,7 +83,7 @@ in { -o ${exe} # optimize js output ${pkgs.closurecompiler}/bin/closure-compiler \ - ${exe}.jsexe/all.js > $out/static/${exe} + ${exe}/all.js > $out/static/${exe} ''; installPhase = "exit 0"; } // { env = ghcjs; }; -- cgit v1.2.3