push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
{
stdenv,
coreutils,
lib,
installShellFiles,
zlib,
autoPatchelfHook,
fetchurl,
makeWrapper,
callPackage,
jre,
testers,
scala-cli,
}:
let
pname = "scala-cli";
sources = lib.importJSON ./sources.json;
inherit (sources) version assets;
platforms = builtins.attrNames assets;
in
stdenv.mkDerivation {
inherit pname version;
nativeBuildInputs = [
installShellFiles
makeWrapper
]
++ lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
buildInputs =
assert lib.assertMsg (lib.versionAtLeast jre.version "17.0.0") ''
scala-cli requires Java 17 or newer, but ${jre.name} is ${jre.version}
'';
[
coreutils
zlib
stdenv.cc.cc
];
src =
let
asset =
assets."${stdenv.hostPlatform.system}"
or (throw "Unsupported platform ${stdenv.hostPlatform.system}");
in
fetchurl {
url = "https://github.com/Virtuslab/scala-cli/releases/download/v${version}/${asset.asset}";
sha256 = asset.sha256;
};
unpackPhase = ''
runHook preUnpack
gzip -d < $src > scala-cli
runHook postUnpack
'';
installPhase = ''
runHook preInstall
install -Dm755 scala-cli $out/bin/.scala-cli-wrapped
makeWrapper $out/bin/.scala-cli-wrapped $out/bin/scala-cli \
--set JAVA_HOME ${jre.home} \
--argv0 "$out/bin/scala-cli"
runHook postInstall
'';
# We need to call autopatchelf before generating completions
dontAutoPatchelf = true;
postFixup =
lib.optionalString stdenv.hostPlatform.isLinux ''
autoPatchelf $out
''
+ ''
# hack to ensure the completion function looks right
# as $0 is used to generate the compdef directive
mkdir temp
cp $out/bin/.scala-cli-wrapped temp/scala-cli
PATH="./temp:$PATH"
installShellCompletion --cmd scala-cli \
--bash <(scala-cli completions bash) \
--zsh <(scala-cli completions zsh)
'';
meta = with lib; {
homepage = "https://scala-cli.virtuslab.org";
downloadPage = "https://github.com/VirtusLab/scala-cli/releases/v${version}";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.asl20;
description = "Command-line tool to interact with the Scala language";
mainProgram = "scala-cli";
maintainers = with maintainers; [
kubukoz
agilesteel
];
inherit platforms;
};
passthru.updateScript = callPackage ./update.nix { } { inherit platforms pname version; };
passthru.tests.version = testers.testVersion {
package = scala-cli;
command = "scala-cli version --offline";
};
}

View File

@@ -0,0 +1,21 @@
{
"version": "1.9.1",
"assets": {
"aarch64-darwin": {
"asset": "scala-cli-aarch64-apple-darwin.gz",
"sha256": "1hlhhy3ncjfjn1k9cc0k8sl43mjgxbsppjy4igs4an2l88pwi9nk"
},
"aarch64-linux": {
"asset": "scala-cli-aarch64-pc-linux.gz",
"sha256": "1lzqyk253bavn9lmb9isa3qx2ylzags9mglb7j433syih8fv2y5z"
},
"x86_64-darwin": {
"asset": "scala-cli-x86_64-apple-darwin.gz",
"sha256": "1vkbr6nhdfi33402hp60i0b078xbipcg3sc7dfinlikvp4vi6jrm"
},
"x86_64-linux": {
"asset": "scala-cli-x86_64-pc-linux.gz",
"sha256": "03d5m0kdb417yf9zw0pkh0wrqivrvvr7akk2xnznbqqjsxfq4sfx"
}
}
}

View File

@@ -0,0 +1,60 @@
{
lib,
curl,
writeShellScript,
jq,
gnused,
git,
nix,
coreutils,
}:
{
platforms,
pname,
version,
}:
writeShellScript "${pname}-update-script" ''
set -o errexit
PATH=${
lib.makeBinPath [
curl
jq
gnused
git
nix
coreutils
]
}
latest_version=$(curl -s "https://api.github.com/repos/VirtusLab/scala-cli/releases?per_page=1" | jq ".[0].tag_name" --raw-output | sed 's/^v//')
if [[ "${version}" = "$latest_version" ]]; then
echo "The new version same as the old version."
exit 0
fi
nixpkgs=$(git rev-parse --show-toplevel)
sources_json="$nixpkgs/pkgs/by-name/sc/scala-cli/sources.json"
platform_assets=()
for platform in ${lib.concatStringsSep " " platforms}; do
asset=$(jq ".assets.\"$platform\".asset" --raw-output < $sources_json)
release_asset_url="https://github.com/Virtuslab/scala-cli/releases/download/v$latest_version/$asset"
asset_hash=$(nix-prefetch-url "$release_asset_url")
asset_object=$(jq --compact-output --null-input \
--arg asset "$asset" \
--arg sha256 "$asset_hash" \
--arg platform "$platform" \
'{asset: $asset, sha256: $sha256, platform: $platform}')
platform_assets+=($asset_object)
done
printf '%s\n' "''${platform_assets[@]}" | \
jq -s "map ( { (.platform): . | del(.platform) }) | add" | \
jq --arg version $latest_version \
'{ version: $version, assets: . }' > $sources_json
''