2024-11-02 09:17:17 -03:00
|
|
|
{
|
|
|
|
buildGoModule,
|
|
|
|
fetchFromGitHub,
|
|
|
|
installShellFiles,
|
|
|
|
kclvm_cli,
|
|
|
|
kclvm,
|
|
|
|
lib,
|
|
|
|
nix-update-script,
|
|
|
|
stdenv,
|
2024-06-10 13:53:29 +03:00
|
|
|
}:
|
2024-11-02 09:17:17 -03:00
|
|
|
|
|
|
|
buildGoModule rec {
|
2024-06-10 13:53:29 +03:00
|
|
|
pname = "kcl";
|
2025-07-26 14:21:51 +00:00
|
|
|
version = "0.11.3";
|
2024-06-10 13:53:29 +03:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kcl-lang";
|
|
|
|
repo = "cli";
|
2025-04-08 02:51:45 -04:00
|
|
|
rev = "v${version}";
|
2025-07-26 14:21:51 +00:00
|
|
|
hash = "sha256-LJ+Mclw/dMyOeUHg6TAckSbvDGFYCf6mMGzDmiIQVZc=";
|
2024-06-10 13:53:29 +03:00
|
|
|
};
|
|
|
|
|
2025-07-26 14:21:51 +00:00
|
|
|
vendorHash = "sha256-jNQ0g7BGXUoYKV5RkU/f9GrSC3ygeZv83SekAmyKLxc=";
|
2024-07-25 17:39:33 +02:00
|
|
|
|
2024-11-02 09:17:17 -03:00
|
|
|
subPackages = [ "cmd/kcl" ];
|
2024-06-10 13:53:29 +03:00
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-w -s"
|
|
|
|
"-X=kcl-lang.io/cli/pkg/version.version=v${version}"
|
|
|
|
];
|
|
|
|
|
2024-11-02 09:17:17 -03:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
|
|
|
];
|
2024-07-25 17:39:33 +02:00
|
|
|
|
2025-04-14 09:29:14 -04:00
|
|
|
buildInputs = [
|
|
|
|
kclvm
|
|
|
|
kclvm_cli
|
|
|
|
];
|
2024-06-10 13:53:29 +03:00
|
|
|
|
2024-11-02 09:17:17 -03:00
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
for shell in bash fish zsh; do
|
|
|
|
installShellCompletion --cmd kcl \
|
|
|
|
--$shell <($out/bin/kcl completion $shell)
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2024-12-04 13:30:15 +10:00
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
set -o pipefail
|
|
|
|
$out/bin/kcl --version | grep $version
|
|
|
|
$out/bin/kcl <(echo 'hello = "KCL"') | grep "hello: KCL"
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
2024-11-02 09:17:17 -03:00
|
|
|
# By default, libs and bins are stripped. KCL will crash on darwin if they are.
|
|
|
|
dontStrip = stdenv.hostPlatform.isDarwin;
|
2024-06-10 13:53:29 +03:00
|
|
|
|
2024-12-04 13:30:15 +10:00
|
|
|
doCheck = true;
|
2024-06-10 13:53:29 +03:00
|
|
|
|
2024-11-02 09:17:17 -03:00
|
|
|
updateScript = nix-update-script { };
|
2024-06-10 13:53:29 +03:00
|
|
|
|
2024-11-02 09:17:17 -03:00
|
|
|
meta = {
|
2025-06-05 09:11:29 -07:00
|
|
|
description = "Command line interface for KCL programming language";
|
2024-11-02 09:17:17 -03:00
|
|
|
changelog = "https://github.com/kcl-lang/cli/releases/tag/v${version}";
|
2024-06-10 13:53:29 +03:00
|
|
|
homepage = "https://github.com/kcl-lang/cli";
|
2024-11-02 09:17:17 -03:00
|
|
|
license = lib.licenses.asl20;
|
|
|
|
platforms = lib.platforms.linux ++ lib.platforms.darwin;
|
|
|
|
maintainers = with lib.maintainers; [
|
|
|
|
peefy
|
|
|
|
selfuryon
|
|
|
|
];
|
2024-06-10 13:53:29 +03:00
|
|
|
mainProgram = "kcl";
|
2024-11-02 09:17:17 -03:00
|
|
|
broken = stdenv.buildPlatform != stdenv.hostPlatform;
|
2024-06-10 13:53:29 +03:00
|
|
|
};
|
|
|
|
}
|