about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2016-12-24 23:14:58 +0100
committerGitHub <noreply@github.com>2016-12-24 23:14:58 +0100
commit481569e58066bd440cfc03360be1959e6af9f70a (patch)
treea9d84dc8a3fd5c328035b5ece6850dde5715ea30 /pkgs/development
parentbdc880e49df1515c92c2c9f4f2600d57ad7d686b (diff)
parent6db2c983c1d7b2fb994c18b91ce9ed381d4053f4 (diff)
downloadnixlib-481569e58066bd440cfc03360be1959e6af9f70a.tar
nixlib-481569e58066bd440cfc03360be1959e6af9f70a.tar.gz
nixlib-481569e58066bd440cfc03360be1959e6af9f70a.tar.bz2
nixlib-481569e58066bd440cfc03360be1959e6af9f70a.tar.lz
nixlib-481569e58066bd440cfc03360be1959e6af9f70a.tar.xz
nixlib-481569e58066bd440cfc03360be1959e6af9f70a.tar.zst
nixlib-481569e58066bd440cfc03360be1959e6af9f70a.zip
Merge pull request #21339 from sifmelcara/add/crystal-lang
crystal: init at 0.20.3
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/compilers/crystal/default.nix96
-rw-r--r--pkgs/development/tools/build-managers/shards/default.nix28
2 files changed, 124 insertions, 0 deletions
diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix
new file mode 100644
index 000000000000..ed9907a283b5
--- /dev/null
+++ b/pkgs/development/compilers/crystal/default.nix
@@ -0,0 +1,96 @@
+{ stdenv, fetchurl, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm_39, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  version = "0.20.3";
+  name = "crystal-${version}-1";
+  arch =
+    {
+      "x86_64-linux" = "linux-x86_64";
+      "i686-linux" = "linux-i686";
+      "x86_64-darwin" = "darwin-x86_64";
+    }."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
+
+  prebuiltBinary = fetchurl {
+    url = "https://github.com/crystal-lang/crystal/releases/download/${version}/crystal-${version}-1-${arch}.tar.gz";
+    sha256 =
+      {
+        "x86_64-linux" = "c656dc8092a6161262f527df441aaab4ea9dd9a836a013f7155c6378b26b8cd7";
+        "i686-linux" = "85edfa1dda5e712341869bab87f6de0f7c6860e2a04dec2f00e8dc6aa1418611";
+        "x86_64-darwin" = "0088972c5cad9543f262976ae6c8ee1dbcbefdee3a8bedae851998bfa7098637";
+      }."${stdenv.system}" or (throw "system ${stdenv.system} not supported");
+  };
+
+  src = fetchurl {
+    url = "https://github.com/crystal-lang/crystal/archive/${version}.tar.gz";
+    sha256 = "5372ba2a35d885345207047a51b9389f9190fd12389847e7f7298618bcf59ad6";
+  };
+
+  # crystal on Darwin needs libiconv to build
+  buildInputs = [
+    boehmgc libatomic_ops pcre libevent llvm_39 makeWrapper
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    libiconv
+  ];
+
+  libPath = stdenv.lib.makeLibraryPath ([
+    boehmgc libatomic_ops pcre libevent
+  ] ++ stdenv.lib.optionals stdenv.isDarwin [
+    libiconv
+  ]);
+
+  unpackPhase = ''
+    tar zxf ${src}
+    tar zxf ${prebuiltBinary}
+  '';
+
+  sourceRoot = ".";
+
+  fixPrebuiltBinary = if stdenv.isDarwin then ''
+    wrapProgram $(pwd)/crystal-${version}-1/embedded/bin/crystal \
+        --suffix DYLD_LIBRARY_PATH : $libPath
+  ''
+  else ''
+    patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
+      crystal-${version}-1/embedded/bin/crystal
+    patchelf --set-rpath ${ stdenv.lib.makeLibraryPath [ stdenv.cc.cc ] } \
+      crystal-${version}-1/embedded/bin/crystal
+  '';
+
+  buildPhase = ''
+    ${fixPrebuiltBinary}
+
+    cd crystal-${version}
+    make release=1 PATH="../crystal-${version}-1/bin:$PATH"
+    make doc
+  '';
+
+  installPhase = ''
+    install -Dm755 .build/crystal $out/bin/crystal
+    wrapProgram $out/bin/crystal \
+        --suffix CRYSTAL_PATH : $out/lib/crystal \
+        --suffix LIBRARY_PATH : $libPath
+
+    install -dm755 $out/lib/crystal
+    cp -r src/* $out/lib/crystal/
+
+    install -dm755 $out/share/doc/crystal/api
+    cp -r doc/* $out/share/doc/crystal/api/
+    cp -r samples $out/share/doc/crystal/
+
+    install -Dm644 etc/completion.bash $out/share/bash-completion/completions/crystal
+    install -Dm644 etc/completion.zsh $out/share/zsh/site-functions/_crystal
+
+    install -Dm644 LICENSE $out/share/licenses/crystal/LICENSE
+  '';
+
+  dontStrip = true;
+
+  meta = {
+    description = "A compiled language with Ruby like syntax and type inference";
+    homepage = "https://crystal-lang.org/";
+    license = stdenv.lib.licenses.asl20;
+    maintainers = with stdenv.lib.maintainers; [ mingchuan ];
+    platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
+  };
+}
+
diff --git a/pkgs/development/tools/build-managers/shards/default.nix b/pkgs/development/tools/build-managers/shards/default.nix
new file mode 100644
index 000000000000..7db0d89e8b1f
--- /dev/null
+++ b/pkgs/development/tools/build-managers/shards/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, crystal, libyaml, which }:
+
+stdenv.mkDerivation rec {
+  name = "shards-${version}";
+  version = "0.7.1";
+
+  src = fetchurl {
+    url = "https://github.com/crystal-lang/shards/archive/v${version}.tar.gz";
+    sha256 = "31de819c66518479682ec781a39ef42c157a1a8e6e865544194534e2567cb110";
+  };
+
+  buildInputs = [ crystal libyaml which ];
+
+  buildFlags = [ "CRFLAGS=" "release" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/shards $out/bin/
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = "https://crystal-lang.org/";
+    license = licenses.asl20;
+    description = "Dependency manager for the Crystal language";
+    maintainers = with maintainers; [ mingchuan ];
+    platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
+  };
+}