Skip to content

Commit

Permalink
Merge pull request #195606 from geopjr-forks/update/crystal
Browse files Browse the repository at this point in the history
crystal: 1.2 -> 1.7
  • Loading branch information
domenkozar authored Jan 20, 2023
2 parents 5ed4819 + 3597e7e commit 15188f9
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 49 deletions.
83 changes: 42 additions & 41 deletions pkgs/development/compilers/crystal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, fetchurl
, fetchpatch
, lib
, substituteAll
# Dependencies
, boehmgc
, coreutils
Expand All @@ -15,6 +16,7 @@
, libiconv
, libxml2
, libyaml
, libffi
, llvmPackages
, makeWrapper
, openssl
Expand All @@ -32,19 +34,21 @@ let
archs = {
x86_64-linux = "linux-x86_64";
i686-linux = "linux-i686";
x86_64-darwin = "darwin-x86_64";
x86_64-darwin = "darwin-universal";
aarch64-darwin = "darwin-universal";
aarch64-linux = "linux-aarch64";
};

arch = archs.${stdenv.system} or (throw "system ${stdenv.system} not supported");
isAarch64Darwin = stdenv.system == "aarch64-darwin";

checkInputs = [ git gmp openssl readline libxml2 libyaml ];
checkInputs = [ git gmp openssl readline libxml2 libyaml libffi ];

binaryUrl = version: rel:
if arch == archs.aarch64-linux then
"https://dev.alpinelinux.org/archive/crystal/crystal-${version}-aarch64-alpine-linux-musl.tar.gz"
else if arch == archs.x86_64-darwin && lib.versionOlder version "1.2.0" then
"https://github.com/crystal-lang/crystal/releases/download/${version}/crystal-${version}-${toString rel}-darwin-x86_64.tar.gz"
else
"https://github.com/crystal-lang/crystal/releases/download/${version}/crystal-${version}-${toString rel}-${arch}.tar.gz";

Expand All @@ -64,12 +68,11 @@ let
patchShebangs $out/bin/crystal
'';

meta.broken = lib.versionOlder version "1.2.0" && isAarch64Darwin;
meta.platforms = lib.attrNames sha256s;
};

commonBuildInputs = extraBuildInputs: [
boehmgc
libatomic_ops
pcre
libevent
libyaml
Expand All @@ -85,7 +88,7 @@ let
, binary
, doCheck ? true
, extraBuildInputs ? [ ]
, buildFlags ? [ "all" "docs" ]
, buildFlags ? [ "all" "docs" "release=1"]
}:
lib.fix (compiler: stdenv.mkDerivation {
pname = "crystal";
Expand All @@ -98,7 +101,13 @@ let
inherit sha256;
};

patches = lib.optionals (lib.versionOlder version "1.2.0") [
patches = [
(substituteAll {
src = ./tzdata.patch;
inherit tzdata;
})
]
++ lib.optionals (lib.versionOlder version "1.2.0") [
# add support for DWARF5 debuginfo, fixes builds on recent compilers
# the PR is 8 commits from 2019, so just fetch the whole thing
# and hope it doesn't change
Expand All @@ -113,18 +122,14 @@ let
postPatch = ''
export TMP=$(mktemp -d)
export HOME=$TMP
export TMPDIR=$TMP
mkdir -p $HOME/test
# Add dependency of crystal to docs to avoid issue on flag changes between releases
# https://github.com/crystal-lang/crystal/pull/8792#issuecomment-614004782
substituteInPlace Makefile \
--replace 'docs: ## Generate standard library documentation' 'docs: crystal ## Generate standard library documentation'
substituteInPlace src/crystal/system/unix/time.cr \
--replace /usr/share/zoneinfo ${tzdata}/share/zoneinfo
ln -sf spec/compiler spec/std
mkdir -p $TMP/crystal
substituteInPlace spec/std/file_spec.cr \
Expand All @@ -147,13 +152,19 @@ let
# See https://github.com/crystal-lang/crystal/issues/8629
substituteInPlace spec/std/socket/udp_socket_spec.cr \
--replace 'it "joins and transmits to multicast groups"' 'pending "joins and transmits to multicast groups"'
'' + lib.optionalString (stdenv.isDarwin && lib.versionAtLeast version "1.3.0" && lib.versionOlder version "1.7.0") ''
# See https://github.com/NixOS/nixpkgs/pull/195606#issuecomment-1356491277
substituteInPlace spec/compiler/loader/unix_spec.cr \
--replace 'it "parses file paths"' 'pending "parses file paths"'
'';

# Defaults are 4
preBuild = ''
export CRYSTAL_WORKERS=$NIX_BUILD_CORES
export threads=$NIX_BUILD_CORES
export CRYSTAL_CACHE_DIR=$TMP
export MACOSX_DEPLOYMENT_TARGET=10.11
'';


Expand All @@ -163,13 +174,16 @@ let

makeFlags = [
"CRYSTAL_CONFIG_VERSION=${version}"
"progress=1"
];

LLVM_CONFIG = "${llvmPackages.llvm.dev}/bin/llvm-config";

FLAGS = [
"--release"
"--single-module" # needed for deterministic builds
] ++ lib.optionals (lib.versionAtLeast version "1.3.0" && lib.versionOlder version "1.6.1") [
# ffi is only used by the interpreter and its spec are broken on < 1.6.1
"-Dwithout_ffi"
];

# This makes sure we don't keep depending on the previous version of
Expand Down Expand Up @@ -220,58 +234,45 @@ let
export PATH=${lib.makeBinPath checkInputs}:$PATH
'';

passthru.buildBinary = binary;
passthru.buildCrystalPackage = callPackage ./build-package.nix {
crystal = compiler;
};

meta = with lib; {
broken = stdenv.isDarwin && (isAarch64Darwin -> lib.versionOlder version "1.2.0");
inherit (binary.meta) platforms;
description = "A compiled language with Ruby like syntax and type inference";
homepage = "https://crystal-lang.org/";
license = licenses.asl20;
maintainers = with maintainers; [ david50407 manveru peterhoeg ];
platforms = let archNames = builtins.attrNames archs; in
if (lib.versionOlder version "1.2.0") then remove "aarch64-darwin" archNames else archNames;
};
})
);

in
rec {
binaryCrystal_1_0 = genericBinary {
version = "1.0.0";
sha256s = {
x86_64-linux = "1949argajiyqyq09824yj3wjyv88gd8wbf20xh895saqfykiq880";
i686-linux = "0w0f4fwr2ijhx59i7ppicbh05hfmq7vffmgl7lal6im945m29vch";
x86_64-darwin = "01n0rf8zh551vv8wq3h0ifnsai0fz9a77yq87xx81y9dscl9h099";
aarch64-linux = "0sns7l4q3z82qi3dc2r4p63f4s8hvifqzgq56ykwyrvawynjhd53";
};
};

binaryCrystal_1_2 = genericBinary {
version = "1.2.0";
version = "1.2.2";
sha256s = {
aarch64-darwin = "1hrs8cpjxdkcf8mr9qgzilwbg6bakq87sd4yydfsk2f4pqd6g7nf";
x86_64-linux = "sha256-sW5nhihW/6Dkq95i3vJNWs2D1CtQhujhxVbgQCAas6E=";
aarch64-darwin = "sha256-4VB4yYGl1/YeYSsHOZq7fdeQ8IQMfloAPhEU0iKrvxs=";
x86_64-darwin = "sha256-4VB4yYGl1/YeYSsHOZq7fdeQ8IQMfloAPhEU0iKrvxs=";
aarch64-linux = "sha256-QgPKUDFyodqY1+b85AybSpbbr0RmfISdNpB08Wf34jo=";
};
};

crystal_1_0 = generic {
version = "1.0.0";
sha256 = "sha256-RI+a3w6Rr+uc5jRf7xw0tOenR+q6qii/ewWfID6dbQ8=";
binary = binaryCrystal_1_0;
};

crystal_1_1 = generic {
version = "1.1.1";
sha256 = "sha256-hhhT3reia8acZiPsflwfuD638Ll2JiXwMfES1TyGyNQ=";
binary = crystal_1_0;
};

crystal_1_2 = generic {
version = "1.2.2";
sha256 = "sha256-nyOXhsutVBRdtJlJHe2dALl//BUXD1JeeQPgHU4SwiU=";
binary = if isAarch64Darwin then binaryCrystal_1_2 else crystal_1_1;
binary = binaryCrystal_1_2;
extraBuildInputs = [ libatomic_ops ];
};

crystal_1_7 = generic {
version = "1.7.1";
sha256 = "sha256-PaeqqY+rSxntzz+30mJnjxzj2Xgu/BNkolw3Y30aZgk=";
binary = binaryCrystal_1_2;
};

crystal = crystal_1_2;
crystal = crystal_1_7;
}
12 changes: 12 additions & 0 deletions pkgs/development/compilers/crystal/tzdata.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/crystal/system/unix/time.cr b/src/crystal/system/unix/time.cr
index 333b66075..1c29a0e55 100644
--- a/src/crystal/system/unix/time.cr
+++ b/src/crystal/system/unix/time.cr
@@ -43,6 +43,7 @@ module Crystal::System::Time
# Many systems use /usr/share/zoneinfo, Solaris 2 has
# /usr/share/lib/zoneinfo, IRIX 6 has /usr/lib/locale/TZ.
ZONE_SOURCES = {
+ "@tzdata@/share/zoneinfo/",
"/usr/share/zoneinfo/",
"/usr/share/lib/zoneinfo/",
"/usr/lib/locale/TZ/",
4 changes: 2 additions & 2 deletions pkgs/development/tools/ameba/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

crystal.buildCrystalPackage rec {
pname = "ameba";
version = "1.0.1";
version = "1.3.1";

src = fetchFromGitHub {
owner = "crystal-ameba";
repo = "ameba";
rev = "v${version}";
hash = "sha256-dvhGk6IbSV3pxtoIV7+0+qf47hz2TooPhsSwFd2+xkw=";
hash = "sha256-SZ2sBQeZgtPOYioH9eK5MveFtWVGPvgKMrqsCfjoRGM=";
};

format = "make";
Expand Down
12 changes: 6 additions & 6 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8603,7 +8603,7 @@ with pkgs;
inherit (darwin.apple_sdk.frameworks) Security SystemConfiguration;
};

kakoune-cr = callPackage ../tools/misc/kakoune-cr { };
kakoune-cr = callPackage ../tools/misc/kakoune-cr { crystal = crystal_1_2; };

katana = callPackage ../tools/security/katana { };

Expand Down Expand Up @@ -14039,18 +14039,18 @@ with pkgs;
};

inherit (callPackages ../development/compilers/crystal {
llvmPackages = if stdenv.system == "aarch64-darwin" then llvmPackages_11 else llvmPackages_10;
llvmPackages = llvmPackages_13;
stdenv = if stdenv.isDarwin then darwin.apple_sdk_11_0.stdenv else stdenv;
})
crystal_1_0
crystal_1_1
crystal_1_2
crystal_1_7
crystal;

crystal2nix = callPackage ../development/compilers/crystal2nix { };

icr = callPackage ../development/tools/icr { };

scry = callPackage ../development/tools/scry { };
scry = callPackage ../development/tools/scry { crystal = crystal_1_2; };

dasm = callPackage ../development/compilers/dasm { };

Expand Down Expand Up @@ -15086,7 +15086,7 @@ with pkgs;

microscheme = callPackage ../development/compilers/microscheme { };

mint = callPackage ../development/compilers/mint { };
mint = callPackage ../development/compilers/mint { crystal = crystal_1_2; };

mitama-cpp-result = callPackage ../development/libraries/mitama-cpp-result { };

Expand Down

0 comments on commit 15188f9

Please sign in to comment.