From 9f9e9d6433519a3fe2ca0b08942a8ee025e720d4 Mon Sep 17 00:00:00 2001 From: Matt McHenry Date: Wed, 22 Aug 2018 22:09:23 -0400 Subject: elm: 0.18 -> 0.19 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update makeElmStuff to makeDotElm, create elm-elm.nix listing the elm code that elm itself embeds, and pre-fetch it so that the elm build can function offline. also include a versions.dat file, as created during an impure build of elm. set ELM_HOME so that the elm build can find these things. continues #45448 (cherry picked from commit e7d0df84676d51fb0cbfbeb10dd32153489c3565) Signed-off-by: Domen Kožar --- pkgs/development/compilers/elm/default.nix | 37 ++++++++++----- .../development/compilers/elm/packages/elm-elm.nix | 50 +++++++++++++++++++++ pkgs/development/compilers/elm/versions.dat | Bin 0 -> 83377 bytes 3 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 pkgs/development/compilers/elm/packages/elm-elm.nix create mode 100644 pkgs/development/compilers/elm/versions.dat (limited to 'pkgs/development/compilers') diff --git a/pkgs/development/compilers/elm/default.nix b/pkgs/development/compilers/elm/default.nix index b7482efe7f55..51f76f1108af 100644 --- a/pkgs/development/compilers/elm/default.nix +++ b/pkgs/development/compilers/elm/default.nix @@ -6,9 +6,26 @@ # 3) Run ./elm2nix.rb in elm-reactor's directory. # 4) Move the resulting 'package.nix' to 'packages/elm-reactor-elm.nix'. +# the elm binary embeds a piece of pre-compiled elm code, used by 'elm +# reactor'. this means that the build process for 'elm' effectively +# executes 'elm make'. that in turn expects to retrieve the elm +# dependencies of that code (elm/core, etc.) from +# package.elm-lang.org, as well as a cached bit of metadata +# (versions.dat). + +# the makeDotElm function lets us retrieve these dependencies in the +# standard nix way. we have to copy them in (rather than symlink) and +# make them writable because the elm compiler writes other .dat files +# alongside the source code. versions.dat was produced during an +# impure build of this same code; the build complains that it can't +# update this cache, but continues past that warning. + +# finally, we set ELM_HOME to point to these pre-fetched artifacts so +# that the default of ~/.elm isn't used. + let - makeElmStuff = deps: - let json = builtins.toJSON (lib.mapAttrs (name: info: info.version) deps); + makeDotElm = ver: deps: + let versionsDat = ./versions.dat; cmds = lib.mapAttrsToList (name: info: let pkg = stdenv.mkDerivation { @@ -29,15 +46,13 @@ let }; in '' - mkdir -p elm-stuff/packages/${name} - ln -s ${pkg} elm-stuff/packages/${name}/${info.version} + mkdir -p .elm/${ver}/package/${name} + cp -R ${pkg} .elm/${ver}/package/${name}/${info.version} + chmod -R +w .elm/${ver}/package/${name}/${info.version} '') deps; in '' - export HOME=/tmp - mkdir elm-stuff - cat > elm-stuff/exact-dependencies.json <