3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/build-managers/bloop/default.nix
Karol Chmist 58f609160c Bloop: rework bloop packaging
* Include all completions
* Update derivation to make it similar to archlinux packaging
2020-07-28 11:36:42 -07:00

86 lines
2.8 KiB
Nix

{ stdenv
, fetchurl
, coursier
, autoPatchelfHook
, lib
, zlib
}:
stdenv.mkDerivation rec {
pname = "bloop";
version = "1.4.1";
bloop-coursier-channel = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/bloop-coursier.json";
sha256 = "2e6a873183e5e22712913bfdab1331d0a7792167c369fee5be0c83e27572fe12";
};
bloop-bash = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/bash-completions";
sha256 = "da6b7ecd4109bd0ff98b1c452d9dd9d26eee0d28ff604f6c83fb8d3236a6bdd1";
};
bloop-fish = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/fish-completions";
sha256 = "1pa8h81l2498q8dbd83fzipr99myjwxpy8xdgzhvqzdmfv6aa4m0";
};
bloop-zsh = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/zsh-completions";
sha256 = "1xzg0qfkjdmzm3mvg82mc4iia8cl7b6vbl8ng4ir2xsz00zjrlsq";
};
bloop-coursier = stdenv.mkDerivation {
name = "${pname}-coursier-${version}";
phases = [ "installPhase" ];
installPhase = ''
export COURSIER_CACHE=$(pwd)
export COURSIER_JVM_CACHE=$(pwd)
mkdir channel
ln -s ${bloop-coursier-channel} channel/bloop.json
${coursier}/bin/coursier install --install-dir $out --default-channels=false --channel channel --only-prebuilt=true bloop
# Remove binary part of the coursier launcher script to make derivation output hash stable
sed -i '5,$ d' $out/bloop
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "17jskljn0aspvl7s2hadzjmp05blnsrxi8db8pn3lfw40da4yn79";
};
nativeBuildInputs = [ autoPatchelfHook ] ;
phases = [ "installPhase" "fixupPhase" ];
buildInputs = [ stdenv.cc.cc.lib zlib ] ;
installPhase = ''
export COURSIER_CACHE=$(pwd)
export COURSIER_JVM_CACHE=$(pwd)
mkdir -p $out/bin
cp ${bloop-coursier}/bloop $out/bloop
cp ${bloop-coursier}/.bloop.aux $out/.bloop.aux
ln -s $out/bloop $out/bin/bloop
# patch the bloop launcher so that it works when symlinked
sed "s|\$(dirname \"\$0\")|$out|" -i $out/bloop
#Install completions
mkdir -p $out/etc/bash_completion.d
ln -s ${bloop-bash} $out/etc/bash_completion.d/bloop
mkdir -p $out/share/zsh/site-functions
ln -s ${bloop-zsh} $out/share/zsh/site-functions/_bloop
mkdir -p $out/usr/share/fish/vendor_completions.d/
ln -s ${bloop-fish} $out/usr/share/fish/vendor_completions.d/bloop.fish
'';
meta = with stdenv.lib; {
homepage = "https://scalacenter.github.io/bloop/";
license = licenses.asl20;
description = "Bloop is a Scala build server and command-line tool to make the compile and test developer workflows fast and productive in a build-tool-agnostic way.";
maintainers = with maintainers; [ tomahna ];
};
}