summary refs log tree commit diff
path: root/pkgs/development/compilers/crystal/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/crystal/default.nix')
-rw-r--r--pkgs/development/compilers/crystal/default.nix67
1 files changed, 47 insertions, 20 deletions
diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix
index 409ac03d92f..03a914695a0 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;
 
@@ -50,6 +56,8 @@ let
       inherit sha256;
     };
 
+    outputs = [ "out" "lib" "bin" ];
+
     # we are almost able to run the full test suite now
     postPatch = ''
       substituteInPlace src/crystal/system/unix/time.cr \
@@ -72,14 +80,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,22 +94,27 @@ 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 "lib"}/crystal";
+
     # We *have* to add `which` to the PATH or crystal is unable to build stuff
     # later if which is not available.
     installPhase = ''
       runHook preInstall
 
-      install -Dm755 .build/crystal $out/bin/crystal
-      wrapProgram $out/bin/crystal \
-          --suffix PATH : ${lib.makeBinPath [ clang which ]} \
-          --suffix CRYSTAL_PATH : lib:$out/lib/crystal \
-          --suffix LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
-      install -dm755 $out/lib/crystal
-      cp -r src/* $out/lib/crystal/
+      install -Dm755 .build/crystal $bin/bin/crystal
+      wrapProgram $bin/bin/crystal \
+          --suffix PATH : ${lib.makeBinPath [ pkgconfig clang which ]} \
+          --suffix CRYSTAL_PATH : lib:$lib/crystal \
+          --suffix CRYSTAL_LIBRARY_PATH : ${
+            lib.makeLibraryPath (commonBuildInputs extraBuildInputs)
+          }
+      install -dm755 $lib/crystal
+      cp -r src/* $lib/crystal/
 
       install -dm755 $out/share/doc/crystal/api
       cp -r docs/* $out/share/doc/crystal/api/
@@ -119,6 +127,10 @@ let
 
       install -Dm644 -t $out/share/licenses/crystal LICENSE README.md
 
+      mkdir -p $out
+      ln -s $bin/bin $out/bin
+      ln -s $lib $out/lib
+
       runHook postInstall
     '';
 
@@ -147,7 +159,7 @@ let
       maintainers = with maintainers; [ manveru david50407 peterhoeg ];
       platforms = builtins.attrNames archs;
     };
-  }; in compiler;
+  }));
 
 in rec {
   binaryCrystal_0_26 = genericBinary {
@@ -212,7 +224,22 @@ in rec {
     binary = binaryCrystal_0_29;
   };
 
-  crystal = crystal_0_30;
+  crystal_0_31 = generic {
+    version = "0.31.1";
+    sha256  = "1dswxa32w16gnc6yjym12xj7ibg0g6zk3ngvl76lwdjqb1h6lwz8";
+    doCheck = false; # 5 checks are failing now
+    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 {};
 }