crystal: reduce closure size of compiled exes by splitting outputs

This commit is contained in:
Michael Fellinger 2019-12-15 22:05:30 +01:00
parent 169fb13569
commit 42cc7428bc
No known key found for this signature in database
GPG Key ID: F4D029589C005F89

View File

@ -56,6 +56,8 @@ let
inherit sha256; inherit sha256;
}; };
outputs = [ "out" "lib" "bin" ];
# we are almost able to run the full test suite now # we are almost able to run the full test suite now
postPatch = '' postPatch = ''
substituteInPlace src/crystal/system/unix/time.cr \ substituteInPlace src/crystal/system/unix/time.cr \
@ -97,22 +99,22 @@ let
# This makes sure we don't keep depending on the previous version of # This makes sure we don't keep depending on the previous version of
# crystal used to build this one. # crystal used to build this one.
CRYSTAL_LIBRARY_PATH = "${placeholder "out"}/lib/crystal"; CRYSTAL_LIBRARY_PATH = "${placeholder "lib"}/crystal";
# We *have* to add `which` to the PATH or crystal is unable to build stuff # We *have* to add `which` to the PATH or crystal is unable to build stuff
# later if which is not available. # later if which is not available.
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
install -Dm755 .build/crystal $out/bin/crystal install -Dm755 .build/crystal $bin/bin/crystal
wrapProgram $out/bin/crystal \ wrapProgram $bin/bin/crystal \
--suffix PATH : ${lib.makeBinPath [ pkgconfig clang which ]} \ --suffix PATH : ${lib.makeBinPath [ pkgconfig clang which ]} \
--suffix CRYSTAL_PATH : lib:$out/lib/crystal \ --suffix CRYSTAL_PATH : lib:$lib/crystal \
--suffix CRYSTAL_LIBRARY_PATH : ${ --suffix CRYSTAL_LIBRARY_PATH : ${
lib.makeLibraryPath (commonBuildInputs extraBuildInputs) lib.makeLibraryPath (commonBuildInputs extraBuildInputs)
} }
install -dm755 $out/lib/crystal install -dm755 $lib/crystal
cp -r src/* $out/lib/crystal/ cp -r src/* $lib/crystal/
install -dm755 $out/share/doc/crystal/api install -dm755 $out/share/doc/crystal/api
cp -r docs/* $out/share/doc/crystal/api/ cp -r docs/* $out/share/doc/crystal/api/
@ -125,6 +127,10 @@ let
install -Dm644 -t $out/share/licenses/crystal LICENSE README.md 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 runHook postInstall
''; '';