diff --git a/pkgs/development/compilers/crystal/default.nix b/pkgs/development/compilers/crystal/default.nix index b3fa16f641341..af4d3a19337c8 100644 --- a/pkgs/development/compilers/crystal/default.nix +++ b/pkgs/development/compilers/crystal/default.nix @@ -4,6 +4,7 @@ , fetchurl , fetchpatch , lib +, substituteAll # Dependencies , boehmgc , coreutils @@ -15,6 +16,7 @@ , libiconv , libxml2 , libyaml +, libffi , llvmPackages , makeWrapper , openssl @@ -32,7 +34,7 @@ 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"; }; @@ -40,11 +42,13 @@ let 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"; @@ -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 @@ -85,7 +88,7 @@ let , binary , doCheck ? true , extraBuildInputs ? [ ] - , buildFlags ? [ "all" "docs" ] + , buildFlags ? [ "all" "docs" "release=1"] }: lib.fix (compiler: stdenv.mkDerivation { pname = "crystal"; @@ -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 @@ -113,6 +122,7 @@ 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 @@ -120,11 +130,6 @@ let 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 \ @@ -147,6 +152,11 @@ 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 @@ -154,6 +164,7 @@ let export CRYSTAL_WORKERS=$NIX_BUILD_CORES export threads=$NIX_BUILD_CORES export CRYSTAL_CACHE_DIR=$TMP + export MACOSX_DEPLOYMENT_TARGET=10.11 ''; @@ -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 @@ -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; } diff --git a/pkgs/development/compilers/crystal/tzdata.patch b/pkgs/development/compilers/crystal/tzdata.patch new file mode 100644 index 0000000000000..b687336753ad9 --- /dev/null +++ b/pkgs/development/compilers/crystal/tzdata.patch @@ -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/", diff --git a/pkgs/development/tools/ameba/default.nix b/pkgs/development/tools/ameba/default.nix index 4239f5c0056a9..27068cbc4c49f 100644 --- a/pkgs/development/tools/ameba/default.nix +++ b/pkgs/development/tools/ameba/default.nix @@ -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"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3c217d816e514..ce7abad052b82 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8551,7 +8551,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 { }; @@ -13972,18 +13972,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 { }; @@ -15056,7 +15056,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 { };