diff options
author | Ben Sima <ben@bsima.me> | 2020-04-10 14:46:45 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2020-04-10 14:46:45 -0700 |
commit | 72af3505b2882b090c833532eff9204a46004dcd (patch) | |
tree | 03e480f21eb9a8af026751bb6776a159598b036c /biz.nix | |
parent | d0b74c55a07ce9e623578bf35d37a597e1a3c179 (diff) |
Get the ghcjs build working
Diffstat (limited to 'biz.nix')
-rw-r--r-- | biz.nix | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -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; }; |