nixpkgs/pkgs/development/compilers/elm/default.nix

89 lines
3.4 KiB
Nix
Raw Normal View History

{ lib, stdenv, pkgs
, haskell, nodejs
, fetchurl, fetchpatch, makeWrapper, writeScriptBin }:
let
fetchElmDeps = import ./fetchElmDeps.nix { inherit stdenv lib fetchurl; };
2019-10-21 16:31:02 +02:00
hsPkgs = haskell.packages.ghc881.override {
2018-08-25 12:52:48 +02:00
overrides = self: super: with haskell.lib;
let elmPkgs = rec {
2018-08-25 13:01:52 +02:00
elm = overrideCabal (self.callPackage ./packages/elm.nix { }) (drv: {
2018-08-25 12:52:48 +02:00
# sadly with parallelism most of the time breaks compilation
enableParallelBuilding = false;
preConfigure = self.fetchElmDeps {
elmPackages = (import ./packages/elm-srcs.nix);
2019-10-21 16:31:02 +02:00
elmVersion = drv.version;
registryDat = ./registry.dat;
};
2018-08-25 13:01:52 +02:00
buildTools = drv.buildTools or [] ++ [ makeWrapper ];
2019-01-04 14:03:24 +01:00
jailbreak = true;
2018-08-25 13:01:52 +02:00
postInstall = ''
wrapProgram $out/bin/elm \
--prefix PATH ':' ${lib.makeBinPath [ nodejs ]}
'';
2018-08-25 12:52:48 +02:00
});
/*
2018-10-03 20:41:58 +02:00
The elm-format expression is updated via a script in the https://github.com/avh4/elm-format repo:
`package/nix/build.sh`
*/
elm-format = justStaticExecutables (overrideCabal (self.callPackage ./packages/elm-format.nix {}) (drv: {
# GHC 8.8.1 support
# https://github.com/avh4/elm-format/pull/640
patches = [(
fetchpatch {
url = "https://github.com/turboMaCk/elm-format/commit/4f4abdc7117ed6ce3335f6cf39b6495b48067b7c.patch";
sha256 = "1zqk6q6w0ph12mnwffgwzf4h1hcgqg0v09ws9q2g5bg2riq4rvd9";
}
)];
# Tests are failing after upgrade to ghc881.
# Cause is probably just a minor change in stdout output
# see https://github.com/avh4/elm-format/pull/640
doCheck = false;
jailbreak = true;
}));
2019-10-21 16:31:02 +02:00
elmi-to-json = justStaticExecutables (overrideCabal (self.callPackage ./packages/elmi-to-json.nix {}) (drv: {
prePatch = ''
2019-10-21 16:31:02 +02:00
substituteInPlace package.yaml --replace "- -Werror" ""
hpack
'';
jailbreak = true;
}));
inherit fetchElmDeps;
2019-01-04 14:03:24 +01:00
elmVersion = elmPkgs.elm.version;
};
in elmPkgs // {
inherit elmPkgs;
2018-08-25 12:52:48 +02:00
# Needed for elm-format
indents = self.callPackage ./packages/indents.nix {};
};
};
2019-09-29 12:57:55 +02:00
/*
Node/NPM based dependecies can be upgraded using script
`packages/generate-node-packages.sh`.
Packages which rely on `bin-wrap` will fail by default
and can be patched using `patchBinwrap` function defined in `packages/patch-binwrap.nix`.
*/
elmNodePackages =
let
nodePkgs = import ./packages/node-composition.nix {
inherit nodejs pkgs;
inherit (stdenv.hostPlatform) system;
};
in with hsPkgs.elmPkgs; {
elm-test = patchBinwrap [elmi-to-json] nodePkgs.elm-test;
elm-verify-examples = patchBinwrap [elmi-to-json] nodePkgs.elm-verify-examples;
elm-language-server = nodePkgs."@elm-tooling/elm-language-server";
inherit (nodePkgs) elm-doc-preview elm-live elm-upgrade elm-xref elm-analyse;
2019-09-29 12:57:55 +02:00
};
patchBinwrap = import ./packages/patch-binwrap.nix { inherit lib writeScriptBin stdenv; };
in hsPkgs.elmPkgs // elmNodePackages // {
lib = { inherit patchBinwrap; };
}