summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--biz.nix23
-rw-r--r--default.nix2
-rw-r--r--deps.nix45
-rwxr-xr-xrepl9
4 files changed, 66 insertions, 13 deletions
diff --git a/biz.nix b/biz.nix
index 1194758..576d3c4 100644
--- a/biz.nix
+++ b/biz.nix
@@ -9,22 +9,33 @@ let
# general functions to put in a lib
lines = s: strings.splitString "\n" s;
- seq = ls: builtins.filter (x: x!= null) ls;
+ removeNull = ls: builtins.filter (x: x != null) ls;
+
depsToPackageSet = packageSet: deps:
- map (s: builtins.getAttr s packageSet) deps;
+ 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;
+
+ allDeps = import ./deps.nix;
in {
buildGhc = main:
let
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)));
- ghc = pkgs.haskell.packages.ghc865.ghcWithHoogle (hp: depsToPackageSet hp deps);
+ 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)}")
+ );
in stdenv.mkDerivation {
name = module;
version = "0";
@@ -82,4 +93,6 @@ in {
'';
installPhase = "exit 0";
} // { env = ghcjs; };
+
+ globalGhc = pkgs.haskell.packages.ghc865.ghcWithHoogle (hp: depsToPackageSet hp allDeps);
}
diff --git a/default.nix b/default.nix
index b15b925..9ac2286 100644
--- a/default.nix
+++ b/default.nix
@@ -77,4 +77,6 @@ in rec {
Com.MusicMeetsComics.Client = biz.buildGhcjs Com/MusicMeetsComics/Client.hs;
Run.Que.Server = biz.buildGhc ./Run/Que/Server.hs;
Run.Que.Website = biz.buildGhc ./Run/Que/Website.hs;
+ # Development environment
+ repl = biz.globalGhc;
}
diff --git a/deps.nix b/deps.nix
new file mode 100644
index 0000000..18d29bc
--- /dev/null
+++ b/deps.nix
@@ -0,0 +1,45 @@
+[
+ "MonadRandom"
+ "acid-state"
+ "aeson"
+ "async"
+ "blaze-html"
+ "blaze-markup"
+ "bytestring"
+ "clay"
+ "containers"
+ "dhall"
+ "ekg"
+ "fast-logger"
+ "ghcjs-base"
+ "http-types"
+ "ixset"
+ "katip"
+ "lucid"
+ "miso"
+ "monad-logger"
+ "monad-metrics"
+ "mtl"
+ "network-uri"
+ "process"
+ "protolude"
+ "random"
+ "req"
+ "safe"
+ "safecopy"
+ "scotty"
+ "servant"
+ "servant-lucid"
+ "servant-server"
+ "split"
+ "stm"
+ "string-quote"
+ "text"
+ "unagi-chan"
+ "unordered-containers"
+ "wai"
+ "wai-app-static"
+ "wai-extra"
+ "wai-middleware-metrics"
+ "warp"
+]
diff --git a/repl b/repl
index 40528c7..b09bb5a 100755
--- a/repl
+++ b/repl
@@ -1,11 +1,4 @@
#!/usr/bin/env bash
set -ex
-prefix=$(echo $PWD | sed -e "s|^$BIZ_ROOT/*||" -e "s|/|.|g")
-if [[ "$prefix" == "" ]]
-then
- target="$1"
-else
- target="$prefix.$1"
-fi
-nix run -f $BIZ_ROOT/default.nix "$target.env" \
+nix run -f $BIZ_ROOT/default.nix "repl" \
-c ghci -i$BIZ_ROOT -ghci-script "$BIZ_ROOT/.ghci"