2024-07-01 15:47:52 +00:00
|
|
|
{ lib
|
2024-07-27 06:49:29 +00:00
|
|
|
, stdenv
|
2024-07-01 15:47:52 +00:00
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, kclvm_cli
|
|
|
|
, kclvm
|
|
|
|
, makeWrapper
|
|
|
|
, installShellFiles
|
2024-07-27 06:49:29 +00:00
|
|
|
, darwin
|
2024-07-01 15:47:52 +00:00
|
|
|
,
|
|
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "kcl";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "0.9.3";
|
2024-07-01 15:47:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kcl-lang";
|
|
|
|
repo = "cli";
|
|
|
|
rev = "v${version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-QUVTRlzG8hT+iQx5dSycbRDAyeknjwGOWynCRw3oxlo=";
|
2024-07-01 15:47:52 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
vendorHash = "sha256-AP1MOlnoTnD7luNR+1QtAdMiJL8tEEwJocT+9wBRgAo=";
|
|
|
|
|
|
|
|
# By default, libs and bins are stripped. KCL will crash on darwin if they are.
|
|
|
|
dontStrip = stdenv.isDarwin;
|
2024-07-01 15:47:52 +00:00
|
|
|
|
|
|
|
ldflags = [
|
|
|
|
"-w -s"
|
|
|
|
"-X=kcl-lang.io/cli/pkg/version.version=v${version}"
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper installShellFiles ];
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
buildInputs = [ kclvm kclvm_cli ] ++ (
|
|
|
|
lib.optional stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.Security
|
|
|
|
darwin.apple_sdk.frameworks.CoreServices
|
|
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
|
|
]
|
|
|
|
);
|
2024-07-01 15:47:52 +00:00
|
|
|
|
|
|
|
subPackages = [ "cmd/kcl" ];
|
|
|
|
|
|
|
|
# env vars https://github.com/kcl-lang/kcl-go/blob/main/pkg/env/env.go#L29
|
|
|
|
postFixup = ''
|
|
|
|
wrapProgram $out/bin/kcl \
|
2024-07-27 06:49:29 +00:00
|
|
|
--prefix PATH : "${lib.makeBinPath [kclvm kclvm_cli]}" \
|
|
|
|
--prefix KCL_LIB_HOME : "${lib.makeLibraryPath [kclvm]}" \
|
|
|
|
--prefix KCL_GO_DISABLE_INSTALL_ARTIFACT : false
|
2024-07-01 15:47:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
2024-07-27 06:49:29 +00:00
|
|
|
export HOME=$(mktemp -d)
|
2024-07-01 15:47:52 +00:00
|
|
|
installShellCompletion --cmd kcl \
|
|
|
|
--bash <($out/bin/kcl completion bash) \
|
|
|
|
--fish <($out/bin/kcl completion fish) \
|
|
|
|
--zsh <($out/bin/kcl completion zsh)
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A command line interface for KCL programming language";
|
|
|
|
homepage = "https://github.com/kcl-lang/cli";
|
|
|
|
license = licenses.asl20;
|
2024-07-27 06:49:29 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2024-07-01 15:47:52 +00:00
|
|
|
maintainers = with maintainers; [ selfuryon peefy ];
|
|
|
|
mainProgram = "kcl";
|
|
|
|
};
|
|
|
|
}
|