about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorSergey Yakovlev2024-06-10 13:53:29 +0300
committerSergey Yakovlev2024-06-13 13:34:25 +0300
commite92c574d1e39a029c9ed373a51f659d7d0f540b3 (patch)
tree024e1637713e5416ec09d03b960d045399eb06ae /pkgs
parente95ac7643cbf3c92e558583d27d967f956ab7958 (diff)
kcl: rename kcl-cli to kcl
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/by-name/kc/kcl-cli/package.nix27
-rw-r--r--pkgs/by-name/kc/kcl/package.nix56
2 files changed, 56 insertions, 27 deletions
diff --git a/pkgs/by-name/kc/kcl-cli/package.nix b/pkgs/by-name/kc/kcl-cli/package.nix
deleted file mode 100644
index f289d19e3eff..000000000000
--- a/pkgs/by-name/kc/kcl-cli/package.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-{ lib
-, buildGoModule
-, fetchFromGitHub
-}:
-
-buildGoModule rec {
-  pname = "kcl-cli";
-  version = "0.8.9";
-  src = fetchFromGitHub {
-    owner = "kcl-lang";
-    repo = "cli";
-    rev = "v${version}";
-    hash = "sha256-slU3n7YCV5VfvXArzlcITb9epdu/gyXlAWq9KLjGdJA=";
-  };
-  vendorHash = "sha256-Xv8Tfq9Kb1xGFCWZQwBFDX9xZW9j99td/DUb7jBtkpE=";
-  ldflags = [
-    "-X=kcl-lang.io/cli/pkg/version.version=${version}"
-  ];
-  subPackages = [ "cmd/kcl" ];
-  meta = with lib; {
-    description = "Command line interface for KCL programming language";
-    homepage = "https://github.com/kcl-lang/cli";
-    license = licenses.asl20;
-    maintainers = with maintainers; [ peefy ];
-    mainProgram = "kcl";
-  };
-}
diff --git a/pkgs/by-name/kc/kcl/package.nix b/pkgs/by-name/kc/kcl/package.nix
new file mode 100644
index 000000000000..6c02da1f986f
--- /dev/null
+++ b/pkgs/by-name/kc/kcl/package.nix
@@ -0,0 +1,56 @@
+{ lib
+, buildGoModule
+, fetchFromGitHub
+, kclvm_cli
+, kclvm
+, makeWrapper
+, installShellFiles
+,
+}:
+buildGoModule rec {
+  pname = "kcl";
+  version = "0.8.9";
+
+  src = fetchFromGitHub {
+    owner = "kcl-lang";
+    repo = "cli";
+    rev = "v${version}";
+    hash = "sha256-slU3n7YCV5VfvXArzlcITb9epdu/gyXlAWq9KLjGdJA=";
+  };
+
+  vendorHash = "sha256-Xv8Tfq9Kb1xGFCWZQwBFDX9xZW9j99td/DUb7jBtkpE=";
+
+  ldflags = [
+    "-w -s"
+    "-X=kcl-lang.io/cli/pkg/version.version=v${version}"
+  ];
+
+  nativeBuildInputs = [ makeWrapper installShellFiles ];
+  buildInputs = [ kclvm kclvm_cli ];
+
+  subPackages = [ "cmd/kcl" ];
+
+  # env vars https://github.com/kcl-lang/kcl-go/blob/main/pkg/env/env.go#L29
+  postFixup = ''
+     wrapProgram $out/bin/kcl \
+    --set PATH ${lib.makeBinPath [kclvm_cli]} \
+    --set KCL_LIB_HOME ${lib.makeLibraryPath [kclvm]} \
+    --set KCL_GO_DISABLE_INSTALL_ARTIFACT false \
+  '';
+
+  postInstall = ''
+    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;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ selfuryon peefy ];
+    mainProgram = "kcl";
+  };
+}