summary refs log tree commit diff
path: root/pkgs/development/compilers/crystal
diff options
context:
space:
mode:
authorMichael Fellinger <michael.fellinger@iohk.io>2019-11-29 21:39:12 +0100
committerMichael Fellinger <michael.fellinger@iohk.io>2019-11-30 15:35:16 +0100
commitaa2c03f1cefeceb981a02d6ac2d0762e8595b751 (patch)
treeefe8da0dd1a555a59cb0ba0979ecc04e54e02779 /pkgs/development/compilers/crystal
parent9c8528e0954904ba76f7950e7ebd74210152ad19 (diff)
downloadnixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.tar
nixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.tar.gz
nixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.tar.bz2
nixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.tar.lz
nixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.tar.xz
nixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.tar.zst
nixpkgs-aa2c03f1cefeceb981a02d6ac2d0762e8595b751.zip
crystal: reduce closure size, more robust runtime
Diffstat (limited to 'pkgs/development/compilers/crystal')
-rw-r--r--pkgs/development/compilers/crystal/default.nix42
1 files changed, 28 insertions, 14 deletions
diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix
index 4032f0b5e92..095f94143e3 100644
--- a/pkgs/development/compilers/crystal/default.nix
+++ b/pkgs/development/compilers/crystal/default.nix
@@ -1,6 +1,6 @@
 { stdenv, lib, fetchFromGitHub, fetchurl, makeWrapper
 , coreutils, git, gmp, nettools, openssl_1_0_2, readline, tzdata, libxml2, libyaml
-, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm, clang, which, zlib
+, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm, clang, which, zlib, pkgconfig
 , callPackage }:
 
 # We need multiple binaries as a given binary isn't always able to build
@@ -38,8 +38,14 @@ let
     '';
   };
 
-  generic = { version, sha256, binary, doCheck ? true }:
-  let compiler = stdenv.mkDerivation rec {
+  commonBuildInputs = extraBuildInputs: [
+    boehmgc libatomic_ops pcre libevent libyaml zlib libxml2 openssl_1_0_2
+  ] ++ extraBuildInputs
+    ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv ];
+
+
+  generic = ({ version, sha256, binary, doCheck ? true, extraBuildInputs ? [] }:
+  lib.fix (compiler: stdenv.mkDerivation {
     pname = "crystal";
     inherit doCheck version;
 
@@ -72,14 +78,9 @@ let
         --replace '`hostname`' '`${nettools}/bin/hostname`'
     '';
 
-    buildInputs = [
-      boehmgc libatomic_ops pcre libevent libyaml
-      llvm zlib openssl_1_0_2
-    ] ++ stdenv.lib.optionals stdenv.isDarwin [
-      libiconv
-    ];
+    buildInputs = commonBuildInputs extraBuildInputs;
 
-    nativeBuildInputs = [ binary makeWrapper which ];
+    nativeBuildInputs = [ binary makeWrapper which pkgconfig llvm ];
 
     makeFlags = [
       "CRYSTAL_CONFIG_VERSION=${version}"
@@ -91,10 +92,13 @@ let
 
     FLAGS = [
       "--release"
-      "--no-debug"
       "--single-module" # needed for deterministic builds
     ];
 
+    # This makes sure we don't keep depending on the previous version of
+    # crystal used to build this one.
+    CRYSTAL_LIBRARY_PATH = "${placeholder "out"}/lib/crystal";
+
     # We *have* to add `which` to the PATH or crystal is unable to build stuff
     # later if which is not available.
     installPhase = ''
@@ -102,9 +106,11 @@ let
 
       install -Dm755 .build/crystal $out/bin/crystal
       wrapProgram $out/bin/crystal \
-          --suffix PATH : ${lib.makeBinPath [ clang which ]} \
+          --suffix PATH : ${lib.makeBinPath [ pkgconfig clang which ]} \
           --suffix CRYSTAL_PATH : lib:$out/lib/crystal \
-          --suffix LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
+          --suffix CRYSTAL_LIBRARY_PATH : ${
+            lib.makeLibraryPath (commonBuildInputs extraBuildInputs)
+          }
       install -dm755 $out/lib/crystal
       cp -r src/* $out/lib/crystal/
 
@@ -147,7 +153,7 @@ let
       maintainers = with maintainers; [ manveru david50407 peterhoeg ];
       platforms = builtins.attrNames archs;
     };
-  }; in compiler;
+  }));
 
 in rec {
   binaryCrystal_0_26 = genericBinary {
@@ -219,6 +225,14 @@ in rec {
     binary = crystal_0_30;
   };
 
+  crystal_0_32 = generic {
+    version = "255bfc5fa925b95b72e34b26ad997fb2b3f83059";
+    sha256  = "1dgk36cj5lwhs1c4zp0s1c9hjk0h3vljq6zwhlnzkl1xs7cgzim1";
+    doCheck = false; # 5 checks are failing now
+    binary = crystal_0_31;
+    extraBuildInputs = [ readline ];
+  };
+
   crystal = crystal_0_31;
 
   crystal2nix = callPackage ./crystal2nix.nix {};