git.iko.soy/typeable/nixpkgs
on master help sign in
crystal: refactor and add 0.35.1
commitbc029589d497af96c4367462200e7690dd61ae69 authorFabián Heredia Montiel <fabianhjr@protonmail.com> dateMon 16 Nov 2020, 13:32 (6 years ago) parent224e1d5
2 files changed+167−130
pkgs/development/compilers/crystal/default.nix+165−129 pkgs/top-level/all-packages.nix+2−1
pkgs/development/compilers/crystal/default.nix+165−129
@@ -1,7 +1,29 @@
1−{ stdenv, lib, fetchFromGitHub, fetchurl, makeWrapper
2−, coreutils, git, gmp, hostname, openssl, readline, tzdata, libxml2, libyaml
3−, boehmgc, libatomic_ops, pcre, libevent, libiconv, llvm, clang, which, zlib, pkgconfig
4−, callPackage }:
1+{ stdenv
2+, callPackage
3+, fetchFromGitHub
4+, fetchurl
5+, lib
6+# Dependencies
7+, boehmgc
8+, coreutils
9+, git
10+, gmp
11+, hostname
12+, libatomic_ops
13+, libevent
14+, libiconv
15+, libxml2
16+, libyaml
17+, llvmPackages
18+, makeWrapper
19+, openssl
20+, pcre
21+, pkgconfig
22+, readline
23+, tzdata
24+, which
25+, zlib
26+}:
527
628# We need multiple binaries as a given binary isn't always able to build
729# (even slightly) older or newer versions.
@@ -43,144 +65,152 @@ let
4365 ] ++ extraBuildInputs
4466 ++ stdenv.lib.optionals stdenv.isDarwin [ libiconv ];
4567
68+ generic = (
69+ { version
70+ , sha256
71+ , binary
72+ , doCheck ? true
73+ , extraBuildInputs ? []
74+ , buildFlags ? ["all" "docs"]
75+ }:
76+ lib.fix (compiler: stdenv.mkDerivation {
77+ pname = "crystal";
78+ inherit buildFlags doCheck version;
79+
80+ src = fetchFromGitHub {
81+ owner = "crystal-lang";
82+ repo = "crystal";
83+ rev = version;
84+ inherit sha256;
85+ };
86+
87+ outputs = [ "out" "lib" "bin" ];
4688
47− generic = ({ version, sha256, binary, doCheck ? true, extraBuildInputs ? [] }:
48− lib.fix (compiler: stdenv.mkDerivation {
49− pname = "crystal";
50− inherit doCheck version;
89+ postPatch = ''
90+ # Add dependency of crystal to docs to avoid issue on flag changes between releases
91+ # https://github.com/crystal-lang/crystal/pull/8792#issuecomment-614004782
92+ substituteInPlace Makefile \
93+ --replace 'docs: ## Generate standard library documentation' 'docs: crystal ## Generate standard library documentation'
5194
52− src = fetchFromGitHub {
53− owner = "crystal-lang";
54− repo = "crystal";
55− rev = version;
56− inherit sha256;
57− };
58−
59− outputs = [ "out" "lib" "bin" ];
60−
61− postPatch = ''
62− substituteInPlace src/crystal/system/unix/time.cr \
63− --replace /usr/share/zoneinfo ${tzdata}/share/zoneinfo
64−
65− ln -sf spec/compiler spec/std
66−
67− # Dirty fix for when no sandboxing is enabled
68− rm -rf /tmp/crystal
69− mkdir -p /tmp/crystal
70−
71− substituteInPlace spec/std/file_spec.cr \
72− --replace '/bin/ls' '${coreutils}/bin/ls' \
73− --replace '/usr/share' '/tmp/crystal' \
74− --replace '/usr' '/tmp'
75−
76− substituteInPlace spec/std/process_spec.cr \
77− --replace '/bin/cat' '${coreutils}/bin/cat' \
78− --replace '/bin/ls' '${coreutils}/bin/ls' \
79− --replace '/usr/bin/env' '${coreutils}/bin/env' \
80− --replace '"env"' '"${coreutils}/bin/env"' \
81− --replace '"/usr"' '"/tmp"'
82−
83− substituteInPlace spec/std/socket/tcp_server_spec.cr \
84− --replace '{% if flag?(:gnu) %}"listen: "{% else %}"bind: "{% end %}' '"bind: "'
85−
86− substituteInPlace spec/std/system_spec.cr \
87− --replace '`hostname`' '`${hostname}/bin/hostname`'
88−
89− # See https://github.com/crystal-lang/crystal/pull/8640
90− substituteInPlace spec/std/http/cookie_spec.cr \
91− --replace '01 Jan 2020' '01 Jan #{Time.utc.year + 2}'
92−
93− # See https://github.com/crystal-lang/crystal/issues/8629
94− substituteInPlace spec/std/socket/udp_socket_spec.cr \
95− --replace 'it "joins and transmits to multicast groups"' 'pending "joins and transmits to multicast groups"'
96−
97− # See https://github.com/crystal-lang/crystal/pull/8699
98− substituteInPlace spec/std/xml/xml_spec.cr \
99− --replace 'it "handles errors"' 'pending "handles errors"'
100− '';
101−
102− buildInputs = commonBuildInputs extraBuildInputs;
95+ substituteInPlace src/crystal/system/unix/time.cr \
96+ --replace /usr/share/zoneinfo ${tzdata}/share/zoneinfo
10397
104− nativeBuildInputs = [ binary makeWrapper which pkgconfig llvm ];
98+ ln -sf spec/compiler spec/std
10599
106− makeFlags = [
107− "CRYSTAL_CONFIG_VERSION=${version}"
108− ];
100+ # Dirty fix for when no sandboxing is enabled
101+ rm -rf /tmp/crystal
102+ mkdir -p /tmp/crystal
109103
110− buildFlags = [
111− "all" "docs"
112− ];
104+ substituteInPlace spec/std/file_spec.cr \
105+ --replace '/bin/ls' '${coreutils}/bin/ls' \
106+ --replace '/usr/share' '/tmp/crystal' \
107+ --replace '/usr' '/tmp'
113108
114− LLVM_CONFIG = "${llvm}/bin/llvm-config";
109+ substituteInPlace spec/std/process_spec.cr \
110+ --replace '/bin/cat' '${coreutils}/bin/cat' \
111+ --replace '/bin/ls' '${coreutils}/bin/ls' \
112+ --replace '/usr/bin/env' '${coreutils}/bin/env' \
113+ --replace '"env"' '"${coreutils}/bin/env"' \
114+ --replace '"/usr"' '"/tmp"'
115+
116+ substituteInPlace spec/std/socket/tcp_server_spec.cr \
117+ --replace '{% if flag?(:gnu) %}"listen: "{% else %}"bind: "{% end %}' '"bind: "'
118+
119+ substituteInPlace spec/std/system_spec.cr \
120+ --replace '`hostname`' '`${hostname}/bin/hostname`'
121+
122+ # See https://github.com/crystal-lang/crystal/pull/8640
123+ substituteInPlace spec/std/http/cookie_spec.cr \
124+ --replace '01 Jan 2020' '01 Jan #{Time.utc.year + 2}'
125+
126+ # See https://github.com/crystal-lang/crystal/issues/8629
127+ substituteInPlace spec/std/socket/udp_socket_spec.cr \
128+ --replace 'it "joins and transmits to multicast groups"' 'pending "joins and transmits to multicast groups"'
129+
130+ # See https://github.com/crystal-lang/crystal/pull/8699
131+ substituteInPlace spec/std/xml/xml_spec.cr \
132+ --replace 'it "handles errors"' 'pending "handles errors"'
133+ '';
134+
135+ buildInputs = commonBuildInputs extraBuildInputs;
136+
137+ nativeBuildInputs = [ binary makeWrapper which pkgconfig llvmPackages.llvm ];
138+
139+ makeFlags = [
140+ "CRYSTAL_CONFIG_VERSION=${version}"
141+ ];
142+
143+ LLVM_CONFIG = "${llvmPackages.llvm}/bin/llvm-config";
144+
145+ FLAGS = [
146+ "--release"
147+ "--single-module" # needed for deterministic builds
148+ ];
149+
150+ # This makes sure we don't keep depending on the previous version of
151+ # crystal used to build this one.
152+ CRYSTAL_LIBRARY_PATH = "${placeholder "lib"}/crystal";
153+
154+ # We *have* to add `which` to the PATH or crystal is unable to build
155+ # stuff later if which is not available.
156+ installPhase = ''
157+ runHook preInstall
158+
159+ install -Dm755 .build/crystal $bin/bin/crystal
160+ wrapProgram $bin/bin/crystal \
161+ --suffix PATH : ${lib.makeBinPath [ pkgconfig llvmPackages.clang which ]} \
162+ --suffix CRYSTAL_PATH : lib:$lib/crystal \
163+ --suffix CRYSTAL_LIBRARY_PATH : ${
164+ lib.makeLibraryPath (commonBuildInputs extraBuildInputs)
165+ }
166+ install -dm755 $lib/crystal
167+ cp -r src/* $lib/crystal/
168+
169+ install -dm755 $out/share/doc/crystal/api
170+ cp -r docs/* $out/share/doc/crystal/api/
171+ cp -r samples $out/share/doc/crystal/
115172
116− FLAGS = [
117− "--release"
118− "--single-module" # needed for deterministic builds
119− ];
173+ install -Dm644 etc/completion.bash $out/share/bash-completion/completions/crystal
174+ install -Dm644 etc/completion.zsh $out/share/zsh/site-functions/_crystal
120175
121− # This makes sure we don't keep depending on the previous version of
122− # crystal used to build this one.
123− CRYSTAL_LIBRARY_PATH = "${placeholder "lib"}/crystal";
176+ install -Dm644 man/crystal.1 $out/share/man/man1/crystal.1
124177
125− # We *have* to add `which` to the PATH or crystal is unable to build stuff
126− # later if which is not available.
127− installPhase = ''
128− runHook preInstall
178+ install -Dm644 -t $out/share/licenses/crystal LICENSE README.md
129179
130− install -Dm755 .build/crystal $bin/bin/crystal
131− wrapProgram $bin/bin/crystal \
132− --suffix PATH : ${lib.makeBinPath [ pkgconfig clang which ]} \
133− --suffix CRYSTAL_PATH : lib:$lib/crystal \
134− --suffix CRYSTAL_LIBRARY_PATH : ${
135− lib.makeLibraryPath (commonBuildInputs extraBuildInputs)
136− }
137− install -dm755 $lib/crystal
138− cp -r src/* $lib/crystal/
180+ mkdir -p $out
181+ ln -s $bin/bin $out/bin
182+ ln -s $lib $out/lib
139183
140− install -dm755 $out/share/doc/crystal/api
141− cp -r docs/* $out/share/doc/crystal/api/
142− cp -r samples $out/share/doc/crystal/
184+ runHook postInstall
185+ '';
143186
144− install -Dm644 etc/completion.bash $out/share/bash-completion/completions/crystal
145− install -Dm644 etc/completion.zsh $out/share/zsh/site-functions/_crystal
187+ enableParallelBuilding = true;
146188
147− install -Dm644 man/crystal.1 $out/share/man/man1/crystal.1
189+ dontStrip = true;
148190
149− install -Dm644 -t $out/share/licenses/crystal LICENSE README.md
191+ checkTarget = "compiler_spec";
150192
151− mkdir -p $out
152− ln -s $bin/bin $out/bin
153− ln -s $lib $out/lib
154−
155− runHook postInstall
156− '';
157−
158− enableParallelBuilding = true;
159−
160− dontStrip = true;
161−
162− checkTarget = "spec";
163−
164− preCheck = ''
165− export HOME=/tmp
166− mkdir -p $HOME/test
193+ preCheck = ''
194+ export HOME=/tmp
195+ mkdir -p $HOME/test
167196
168− export LIBRARY_PATH=${lib.makeLibraryPath checkInputs}:$LIBRARY_PATH
169− export PATH=${lib.makeBinPath checkInputs}:$PATH
170− '';
197+ export LIBRARY_PATH=${lib.makeLibraryPath checkInputs}:$LIBRARY_PATH
198+ export PATH=${lib.makeBinPath checkInputs}:$PATH
199+ '';
171200
172− passthru.buildCrystalPackage = callPackage ./build-package.nix {
173− crystal = compiler;
174− };
201+ passthru.buildCrystalPackage = callPackage ./build-package.nix {
202+ crystal = compiler;
203+ };
175204
176− meta = with lib; {
177− description = "A compiled language with Ruby like syntax and type inference";
178− homepage = "https://crystal-lang.org/";
179− license = licenses.asl20;
180− maintainers = with maintainers; [ manveru david50407 peterhoeg ];
181− platforms = builtins.attrNames archs;
182− };
183− }));
205+ meta = with lib; {
206+ description = "A compiled language with Ruby like syntax and type inference";
207+ homepage = "https://crystal-lang.org/";
208+ license = licenses.asl20;
209+ maintainers = with maintainers; [ david50407 fabianhjr manveru peterhoeg ];
210+ platforms = builtins.attrNames archs;
211+ };
212+ })
213+ );
184214
185215in rec {
186216 binaryCrystal_0_31 = genericBinary {
@@ -202,24 +232,30 @@ in rec {
202232 crystal_0_32 = generic {
203233 version = "0.32.1";
204234 sha256 = "120ndi3nhh2r52hjvhwfb49cdggr1bzdq6b8xg7irzavhjinfza6";
205− binary = binaryCrystal_0_31;
235+ binary = crystal_0_31;
206236 };
207237
208238 crystal_0_33 = generic {
209239 version = "0.33.0";
210240 sha256 = "1zg0qixcws81s083wrh54hp83ng2pa8iyyafaha55mzrh8293jbi";
211− binary = binaryCrystal_0_31;
212− doCheck = false; # 4 checks are failing now
241+ binary = crystal_0_32;
213242 };
214243
215244 crystal_0_34 = generic {
216245 version = "0.34.0";
217246 sha256 = "110lfpxk9jnqyznbfnilys65ixj5sdmy8pvvnlhqhc3ccvrlnmq4";
218247 binary = crystal_0_33;
219− doCheck = false; # 4 checks are failing now
220248 };
221249
222− crystal = crystal_0_34;
250+ crystal_0_35 = generic {
251+ version = "0.35.1";
252+ sha256 = "0p51bjl1nsvwsm64lqq421dcsxa201w7wwq8plw4r8wqarpq0g69";
253+ binary = crystal_0_34;
254+ # Needs git to build as per https://github.com/crystal-lang/crystal/issues/9789
255+ extraBuildInputs = [ git ];
256+ };
257+
258+ crystal = crystal_0_35;
223259
224260 crystal2nix = callPackage ./crystal2nix.nix {};
225261}
pkgs/top-level/all-packages.nix+2−1
@@ -8799,12 +8799,13 @@ in
87998799 copper = callPackage ../development/compilers/copper {};
88008800
88018801 inherit (callPackages ../development/compilers/crystal {
8802− inherit (llvmPackages_10) stdenv clang llvm;
8802+ llvmPackages = llvmPackages_10;
88038803 })
88048804 crystal_0_31
88058805 crystal_0_32
88068806 crystal_0_33
88078807 crystal_0_34
8808+ crystal_0_35
88088809 crystal
88098810 crystal2nix;
88108811