1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/pkgs/development/tools/coursier/default.nix

73 lines
2.4 KiB
Nix
Raw Normal View History

2020-11-06 01:54:12 +00:00
{ stdenv, fetchurl, makeWrapper, jre, writeScript, common-updater-scripts
, coreutils, git, gnused, nix, nixfmt }:
2017-03-20 03:58:24 +00:00
2019-08-21 20:00:13 +01:00
let
2020-12-23 22:05:51 +00:00
version = "2.0.8";
2020-11-06 01:54:12 +00:00
zshCompletion = fetchurl {
url =
"https://raw.githubusercontent.com/coursier/coursier/v${version}/modules/cli/src/main/resources/completions/zsh";
2020-10-22 05:11:12 +01:00
sha256 = "0afxzrk9w1qinfsz55jjrxydw0fcv6p722g1q955dl7f6xbab1jh";
2019-08-21 20:00:13 +01:00
};
2020-11-06 01:54:12 +00:00
repo = "git@github.com:coursier/coursier.git";
in stdenv.mkDerivation rec {
inherit version;
pname = "coursier";
2017-03-20 03:58:24 +00:00
src = fetchurl {
2020-11-06 01:54:12 +00:00
url =
"https://github.com/coursier/coursier/releases/download/v${version}/coursier";
2020-12-23 22:05:51 +00:00
sha256 = "sha256-7dNJUMZu6YY3076cnjWHRisJZVn1NPRH1VC+cJjfI/8=";
2017-03-20 03:58:24 +00:00
};
nativeBuildInputs = [ makeWrapper ];
2017-03-20 03:58:24 +00:00
2018-02-22 02:50:17 +00:00
buildCommand = ''
install -Dm555 $src $out/bin/coursier
patchShebangs $out/bin/coursier
wrapProgram $out/bin/coursier --prefix PATH ":" ${jre}/bin
2019-08-21 20:00:13 +01:00
# copy zsh completion
2020-11-06 01:54:12 +00:00
install -Dm755 ${zshCompletion} $out/share/zsh/site-functions/_coursier
'';
passthru.updateScript = writeScript "update.sh" ''
#!${stdenv.shell}
set -o errexit
PATH=${
stdenv.lib.makeBinPath [
common-updater-scripts
coreutils
git
gnused
nix
nixfmt
]
}
oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags ${repo} 'v*.*.*' | tail --lines=1 | cut --delimiter='/' --fields=3 | sed 's|^v||g')"
if [ "$oldVersion" != "$latestTag" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
default_nix="$nixpkgs/pkgs/development/tools/coursier/default.nix"
update-source-version ${pname} "$latestTag" --version-key=version --print-changes
url="${builtins.head zshCompletion.urls}"
completion_url=$(echo $url | sed "s|$oldVersion|$latestTag|g")
completion_sha256="$(nix-prefetch-url --type sha256 $completion_url)"
sed -i "s|${zshCompletion.outputHash}|$completion_sha256|g" "$default_nix"
nixfmt "$default_nix"
else
echo "${pname} is already up-to-date"
fi
2017-03-20 03:58:24 +00:00
'';
meta = with stdenv.lib; {
homepage = "https://get-coursier.io/";
2020-11-06 01:54:12 +00:00
description =
"A Scala library to fetch dependencies from Maven / Ivy repositories";
2017-04-08 20:03:33 +01:00
license = licenses.asl20;
maintainers = with maintainers; [ adelbertc nequissimus ];
2017-03-20 03:58:24 +00:00
};
}