1 { lib, stdenv, fetchurl, makeWrapper, jre, writeScript, common-updater-scripts
2 , coreutils, git, gnused, nix, nixfmt }:
7 zshCompletion = fetchurl {
9 "https://raw.githubusercontent.com/coursier/coursier/v${version}/modules/cli/src/main/resources/completions/zsh";
10 sha256 = "0afxzrk9w1qinfsz55jjrxydw0fcv6p722g1q955dl7f6xbab1jh";
13 repo = "git@github.com:coursier/coursier.git";
14 in stdenv.mkDerivation rec {
21 "https://github.com/coursier/coursier/releases/download/v${version}/coursier";
22 sha256 = "sha256-ZKltN/m4ZyOr98k5z4HfPh6jbRUM6MIew+NWo7UAz9o=";
25 nativeBuildInputs = [ makeWrapper ];
28 install -Dm555 $src $out/bin/cs
29 patchShebangs $out/bin/cs
30 wrapProgram $out/bin/cs --prefix PATH ":" ${jre}/bin
33 install -Dm755 ${zshCompletion} $out/share/zsh/site-functions/_cs
36 passthru.updateScript = writeScript "update.sh" ''
40 lib.makeBinPath [ common-updater-scripts coreutils git gnused nix nixfmt ]
42 oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
43 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')"
44 if [ "$oldVersion" != "$latestTag" ]; then
45 nixpkgs="$(git rev-parse --show-toplevel)"
46 default_nix="$nixpkgs/pkgs/development/tools/coursier/default.nix"
47 update-source-version ${pname} "$latestTag" --version-key=version --print-changes
48 url="${builtins.head zshCompletion.urls}"
49 completion_url=$(echo $url | sed "s|$oldVersion|$latestTag|g")
50 completion_sha256="$(nix-prefetch-url --type sha256 $completion_url)"
51 sed -i "s|${zshCompletion.outputHash}|$completion_sha256|g" "$default_nix"
54 echo "${pname} is already up-to-date"
59 homepage = "https://get-coursier.io/";
61 "A Scala library to fetch dependencies from Maven / Ivy repositories";
62 license = licenses.asl20;
63 maintainers = with maintainers; [ adelbertc nequissimus ];