From e84c5104d5052ceda551cf850842e8bee800c32e Mon Sep 17 00:00:00 2001 From: qwqawawow Date: Sun, 1 Sep 2024 09:35:12 +0800 Subject: [PATCH] groovy: add completion,desktop support --- .../interpreters/groovy/default.nix | 55 +++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/pkgs/development/interpreters/groovy/default.nix b/pkgs/development/interpreters/groovy/default.nix index 8ed9bfe11736..ba597c6e7135 100644 --- a/pkgs/development/interpreters/groovy/default.nix +++ b/pkgs/development/interpreters/groovy/default.nix @@ -1,4 +1,15 @@ -{ lib, stdenv, fetchurl, unzip, which, makeWrapper, jdk }: +{ + lib, + stdenv, + fetchurl, + unzip, + which, + makeWrapper, + installShellFiles, + jdk, + copyDesktopItems, + makeDesktopItem, +}: # at runtime, need jdk @@ -11,12 +22,44 @@ stdenv.mkDerivation rec { sha256 = "sha256-2Ro93+NThx1MJlbT0KBcgovD/zbp1J29vsE9zZjwWHc="; }; - nativeBuildInputs = [ makeWrapper unzip ]; + nativeBuildInputs = [ + makeWrapper + unzip + installShellFiles + copyDesktopItems + ]; + + desktopItems = [ + (makeDesktopItem { + name = "groovy"; + desktopName = "Groovy Console"; + exec = "groovyConsole"; + icon = "groovy"; + comment = meta.description; + terminal = false; + startupNotify = false; + categories = [ "Development" ]; + }) + ]; installPhase = '' + runHook preInstall + + rm bin/*.bat + mkdir -p $out mkdir -p $out/share/doc/groovy - rm bin/*.bat + + #Install icons + mkdir -p $out/share/icons + mv bin/groovy.ico $out/share/icons/ + + #Install Completion + for p in grape groovy{,doc,c,sh,Console}; do + installShellCompletion --cmd $p --bash bin/''${p}_completion + done + rm bin/*_completion + mv {bin,conf,grooid,lib} $out mv {licenses,LICENSE,NOTICE} $out/share/doc/groovy @@ -24,9 +67,11 @@ stdenv.mkDerivation rec { for p in grape java2groovy groovy{,doc,c,sh,Console}; do wrapProgram $out/bin/$p \ - --set JAVA_HOME "${jdk}" \ - --prefix PATH ":" "${jdk}/bin" + --set JAVA_HOME "${jdk}" \ + --prefix PATH ":" "${jdk}/bin" done + + runHook postInstall ''; meta = with lib; {