Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bloop: 1.3.4 -> 1.4.1 #89359

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
109 changes: 56 additions & 53 deletions pkgs/development/tools/build-managers/bloop/default.nix
@@ -1,72 +1,75 @@
{ stdenv, lib, fetchurl, coursier, python, makeWrapper }:

let
baseName = "bloop";
version = "1.3.4";
nailgunCommit = "d7ed5db"; # Fetched from https://github.com/scalacenter/bloop/releases/download/v${version}/install.py

client = stdenv.mkDerivation {
name = "${baseName}-client-${version}";
{ stdenv, fetchurl, coursier,
autoPatchelfHook,
lib, zlib }:

stdenv.mkDerivation rec {
basename = "bloop";
version = "1.4.1";
name = "bloop-${version}";

bloop-coursier-channel = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/bloop-coursier.json";
sha256 = "2e6a873183e5e22712913bfdab1331d0a7792167c369fee5be0c83e27572fe12";
};

src = fetchurl {
url = "https://raw.githubusercontent.com/scalacenter/nailgun/${nailgunCommit}/pynailgun/ng.py";
sha256 = "0lrj25m0nvphz2i5mqjwccpyrd7gn8a5k22k5khrpdh6ldxqis8a";
};
bloop-bash = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/bash-completions";
sha256 = "da6b7ecd4109bd0ff98b1c452d9dd9d26eee0d28ff604f6c83fb8d3236a6bdd1";
};

phases = [ "installPhase" ];
bloop-fish = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/fish-completions";
sha256 = "1pa8h81l2498q8dbd83fzipr99myjwxpy8xdgzhvqzdmfv6aa4m0";
};

installPhase = ''cp $src $out'';
bloop-zsh = fetchurl {
url = "https://github.com/scalacenter/bloop/releases/download/v${version}/zsh-completions";
sha256 = "1xzg0qfkjdmzm3mvg82mc4iia8cl7b6vbl8ng4ir2xsz00zjrlsq";
};

server = stdenv.mkDerivation {
name = "${baseName}-server-${version}";
buildCommand = ''
mkdir -p $out/bin
bloop-coursier = stdenv.mkDerivation {
name = "${basename}-coursier-${version}";

export COURSIER_CACHE=$(pwd)
${coursier}/bin/coursier bootstrap ch.epfl.scala:bloop-frontend_2.12:${version} \
-r "bintray:scalameta/maven" \
-r "bintray:scalacenter/releases" \
-r "https://oss.sonatype.org/content/repositories/staging" \
--deterministic \
-f --main bloop.Server -o $out/bin/blp-server
'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "1z33ip6hgfwiixm2gimz819p5cnxn1fmxb3ryyf77jzwsx7py718";
};
nativeBuildInputs = [ autoPatchelfHook ] ;
phases = [ "installPhase" "fixupPhase" ];
buildInputs = [ stdenv.cc.cc.lib zlib ] ;

zsh = stdenv.mkDerivation {
name = "${baseName}-zshcompletion-${version}";
installPhase = ''
export COURSIER_CACHE=$(pwd)
export COURSIER_JVM_CACHE=$(pwd)

src = fetchurl {
url = "https://raw.githubusercontent.com/scalacenter/bloop/v${version}/etc/zsh/_bloop";
sha256 = "09qq5888vaqlqan2jbs2qajz2c3ff13zj8r0x2pcxsqmvlqr02hp";
};
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

phases = [ "installPhase" ];
# Remove binary part of the coursier launcher script to make derivation output hash stable
sed -i '5,$ d' $out/bloop
'';

installPhase = ''cp $src $out'';
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "1f5hf80s71w5g61s8vcaccabsn9xvkf05jgbnwwx01i3f23w31vb";
};
in
stdenv.mkDerivation {
name = "${baseName}-${version}";

buildInputs = [ makeWrapper ];
buildCommand = ''
export COURSIER_CACHE=$(pwd)
export COURSIER_JVM_CACHE=$(pwd)

phases = [ "installPhase" ];

installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share/zsh/site-functions
cp ${bloop-coursier}/bloop $out/bloop
ln -s ${bloop-coursier}/.bloop.aux $out/.bloop.aux
ln -s $out/bloop $out/bin/bloop

ln -s ${server}/bin/blp-server $out/blp-server
ln -s ${zsh} $out/share/zsh/site-functions/_bloop
# patch the bloop launcher so that it works when symlinked
sed "s|\$(dirname \"\$0\")|$out|" -i $out/bloop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking/optional: this keeps the $(cd "$out" ; pwd) part, and could be replaced wider I'd think... in my version I had #\$(cd "\$(dirname "\$0")"; pwd)/.bloop.aux#'"$out"'/bin/.bloop.aux#


cp ${client} $out/bloop
chmod +x $out/bloop
makeWrapper $out/bloop $out/bin/bloop \
--prefix PATH : ${lib.makeBinPath [ python ]}
#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; {
Expand Down