summary refs log tree commit diff
path: root/pkgs/development/compilers/elm/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/elm/default.nix')
-rw-r--r--pkgs/development/compilers/elm/default.nix81
1 files changed, 81 insertions, 0 deletions
diff --git a/pkgs/development/compilers/elm/default.nix b/pkgs/development/compilers/elm/default.nix
new file mode 100644
index 000000000000..4a056e61de95
--- /dev/null
+++ b/pkgs/development/compilers/elm/default.nix
@@ -0,0 +1,81 @@
+{ lib, stdenv, buildEnv, haskell, nodejs, fetchurl, fetchpatch, makeWrapper }:
+
+let
+  makeElmStuff = deps:
+    let json = builtins.toJSON (lib.mapAttrs (name: info: info.version) deps);
+        cmds = lib.mapAttrsToList (name: info: let
+                 pkg = stdenv.mkDerivation {
+
+                   name = lib.replaceChars ["/"] ["-"] name + "-${info.version}";
+
+                   src = fetchurl {
+                     url = "https://github.com/${name}/archive/${info.version}.tar.gz";
+                     meta.homepage = "https://github.com/${name}/";
+                     inherit (info) sha256;
+                   };
+
+                   phases = [ "unpackPhase" "installPhase" ];
+
+                   installPhase = ''
+                     mkdir -p $out
+                     cp -r * $out
+                   '';
+
+                 };
+               in ''
+                 mkdir -p elm-stuff/packages/${name}
+                 ln -s ${pkg} elm-stuff/packages/${name}/${info.version}
+               '') deps;
+    in ''
+      export HOME=/tmp
+      mkdir elm-stuff
+      cat > elm-stuff/exact-dependencies.json <<EOF
+      ${json}
+      EOF
+    '' + lib.concatStrings cmds;
+
+  hsPkgs = haskell.packages.ghc7102.override {
+    overrides = self: super:
+      let hlib = haskell.lib;
+          elmRelease = import ./packages/release.nix { inherit (self) callPackage; };
+          elmPkgs' = elmRelease.packages;
+          elmPkgs = elmPkgs' // {
+
+            elm-reactor = hlib.overrideCabal elmPkgs'.elm-reactor (drv: {
+              buildTools = drv.buildTools or [] ++ [ self.elm-make ];
+              patches = [ (fetchpatch {
+                url = "https://github.com/elm-lang/elm-reactor/commit/ca4d91d3fc7c6f72aa802d79fd1563ab5f3c4f2c.patch";
+                sha256 = "1msq7rvjid27m11lwcz9r1vyczlk7bfknyywqln300c8bgqyl45j";
+              }) ];
+              preConfigure = makeElmStuff (import ./packages/elm-reactor-elm.nix);
+            });
+
+            elm-package = hlib.appendPatch elmPkgs'.elm-package (fetchpatch {
+              url = "https://github.com/elm-lang/elm-package/commit/af517f2ffe15f8ec1d8c38f01ce188bbdefea47a.patch";
+              sha256 = "0yq5vawmp9qq5w6qfy12r32ahpvccra749pnhg0zdykrj369m8a8";
+            });
+
+            elm-repl = hlib.overrideCabal elmPkgs'.elm-repl (drv: {
+              doCheck = false;
+              buildTools = drv.buildTools or [] ++ [ makeWrapper ];
+              postInstall =
+                let bins = lib.makeSearchPath "bin" [ nodejs self.elm-make ];
+                in ''
+                  wrapProgram $out/bin/elm-repl \
+                    --prefix PATH ':' ${bins}
+                '';
+            });
+
+          };
+      in elmPkgs // {
+        inherit elmPkgs;
+        elmVersion = elmRelease.version;
+      };
+  };
+in hsPkgs.elmPkgs // {
+  elm = buildEnv {
+    name = "elm-${hsPkgs.elmVersion}";
+    paths = lib.mapAttrsToList (name: pkg: pkg) hsPkgs.elmPkgs;
+    pathsToLink = [ "/bin" ];
+  };
+}