Files
nixpkgs/pkgs/by-name/jb/jbang/package.nix
2026-07-21 17:45:04 +00:00

67 lines
1.4 KiB
Nix

{
stdenv,
lib,
fetchzip,
jdk,
makeWrapper,
bashNonInteractive,
coreutils,
curl,
}:
stdenv.mkDerivation rec {
version = "0.141.0";
pname = "jbang";
__structuredAttrs = true;
strictDeps = true;
src = fetchzip {
url = "https://github.com/jbangdev/jbang/releases/download/v${version}/${pname}-${version}.tar";
sha256 = "sha256-fw87WrmqdVH+NJ+rAnuMukz7qMTRg6CMgLVg/+JPahI=";
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
bashNonInteractive
];
installPhase = ''
runHook preInstall
rm bin/jbang.{cmd,ps1}
cp -r . $out
wrapProgram $out/bin/jbang \
--set JAVA_HOME ${jdk} \
--prefix PATH ${
lib.makeBinPath [
(placeholder "out")
coreutils
jdk
curl
]
}
runHook postInstall
'';
installCheckPhase = ''
$out/bin/jbang --version 2>&1 | grep -q "${version}"
'';
meta = {
description = "Run java as scripts anywhere";
mainProgram = "jbang";
longDescription = ''
jbang uses the java language to build scripts similar to groovy scripts. Dependencies are automatically
downloaded and the java code runs.
'';
homepage = "https://www.jbang.dev";
sourceProvenance = with lib.sourceTypes; [
binaryBytecode
];
license = lib.licenses.mit;
platforms = lib.platforms.all;
maintainers = with lib.maintainers; [ moaxcp ];
};
}