bloop: refactor derivation to use subderivations

This change prevents accidentally using cached version of dependencies
when updating the version
This commit is contained in:
Kevin Rauscher 2019-06-15 12:11:40 +02:00
parent 0f4da4a501
commit 3bdd3b158a

View File

@ -3,6 +3,8 @@
let
baseName = "bloop";
version = "1.3.2";
nailgunCommit = "9327a60a"; # Fetched from https://github.com/scalacenter/bloop/releases/download/v${version}/install.py
deps = stdenv.mkDerivation {
name = "${baseName}-deps-${version}";
buildCommand = ''
@ -18,39 +20,53 @@ let
outputHashAlgo = "sha256";
outputHash = "1npq02npk6qiwghgr3bqd1ala1kv8hwq1qkmyffvigcq7frkz4r8";
};
client = stdenv.mkDerivation {
name = "${baseName}-client-${nailgunCommit}";
src = fetchurl {
url = "https://raw.githubusercontent.com/scalacenter/nailgun/${nailgunCommit}/pynailgun/ng.py";
sha256 = "0z4as5ibmzkd145wsch9caiy4037bgg780gcf7pyns0cv9n955b4";
};
phases = [ "installPhase" ];
installPhase = ''
cp $src $out
chmod +x $out
'';
};
zsh = stdenv.mkDerivation {
name = "${baseName}-zshcompletion-${version}";
src = fetchurl {
url = "https://raw.githubusercontent.com/scalacenter/bloop/v${version}/etc/zsh/_bloop";
sha256 = "09qq5888vaqlqan2jbs2qajz2c3ff13zj8r0x2pcxsqmvlqr02hp";
};
phases = [ "installPhase" ];
installPhase = ''cp $src $out'';
};
in
stdenv.mkDerivation rec {
name = "${baseName}-${version}";
# Fetched from https://github.com/scalacenter/bloop/releases/download/v${version}/install.py
nailgunCommit = "9327a60a";
buildInputs = [ jdk makeWrapper deps ];
phases = [ "installPhase" ];
client = fetchurl {
url = "https://raw.githubusercontent.com/scalacenter/nailgun/${nailgunCommit}/pynailgun/ng.py";
sha256 = "0z4as5ibmzkd145wsch9caiy4037bgg780gcf7pyns0cv9n955b4";
};
zshCompletion = fetchurl {
url = "https://raw.githubusercontent.com/scalacenter/bloop/v${version}/etc/zsh/_bloop";
sha256 = "09qq5888vaqlqan2jbs2qajz2c3ff13zj8r0x2pcxsqmvlqr02hp";
};
installPhase = ''
mkdir -p $out/bin
mkdir -p $out/share/zsh/site-functions
cp ${client} $out/bin/blp-client
cp ${zshCompletion} $out/share/zsh/site-functions/_bloop
chmod +x $out/bin/blp-client
ln -s ${zsh} $out/share/zsh/site-functions/_bloop
makeWrapper ${jre}/bin/java $out/bin/blp-server \
--prefix PATH : ${lib.makeBinPath [ jdk ]} \
--add-flags "-cp $CLASSPATH bloop.Server"
makeWrapper $out/bin/blp-client $out/bin/bloop \
makeWrapper ${client} $out/bin/bloop \
--prefix PATH : ${lib.makeBinPath [ python ]}
'';