Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Nix package of KCL CLI and Language Server #1169

Open
vfarcic opened this issue Mar 28, 2024 · 16 comments
Open

[Enhancement] Nix package of KCL CLI and Language Server #1169

vfarcic opened this issue Mar 28, 2024 · 16 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed release

Comments

@vfarcic
Copy link

vfarcic commented Mar 28, 2024

Feature Request

Is your feature request related to a problem? Please describe:
I tend to use nix-shell for all the projects I work on. That way I create ephemeral environments with all the tools I need without installing any of them permanently on my laptop. kcl CLI is not available as a Nix package.

Describe the feature you'd like:
Make kcl available as a Nix package.

Describe alternatives you've considered:
Installing it permanently on my laptop.

Teachability, Documentation, Adoption, Migration Strategy:
Users can start a session with nix-shell or devbox shell and get the tools they need to work on a project, including kcl.

@Peefy Peefy changed the title Nix package [Enhancement] Nix package Mar 28, 2024
@Peefy Peefy added enhancement New feature or request release good first issue Good for newcomers labels Mar 28, 2024
@Peefy Peefy added this to the v0.9.0 Release milestone Mar 28, 2024
@Peefy
Copy link
Contributor

Peefy commented Mar 28, 2024

Hello @vfarcic

Thank you for your feedback. That's a very good suggestion.
Later, I will add it at https://github.com/NixOS/nixpkgs and PRs also welcome. ❤️

@Peefy Peefy added the help wanted Extra attention is needed label Mar 29, 2024
@Peefy Peefy self-assigned this Apr 7, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 7, 2024

The KCL Nix Package PR: NixOS/nixpkgs#302285
The KCL Language Server Nix Package PR: NixOS/nixpkgs#302286

@Peefy
Copy link
Contributor

Peefy commented Apr 10, 2024

The KCL CLI Nix Package PR has been merged 🎉 NixOS/nixpkgs#302488 Note that the Nix community suggests that we use the kcl-cli package, the initial version is 0.8.5. I will update the relevant documents on the KCL website later.

@Peefy
Copy link
Contributor

Peefy commented Apr 17, 2024

image

@Peefy Peefy closed this as completed Apr 17, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 18, 2024

Thank you @diefans for the kcl-nix package: https://github.com/diefans/kcl-nix

@sanzoghenzo
Copy link

Hi, thanks for this!
Is there a reason why the kcl-lsp was not added to nix packages?
It feels a bit awkward to have kcli cli in nix/devbox, but then having to install the lsp manually to make vscode happy...

@Peefy
Copy link
Contributor

Peefy commented Apr 24, 2024

Hello @sanzoghenzo, we have plans to support this, and prior to that, we have done some refactoring and pre work on the kcl-language-server rust project. It is expected that we can provide nix package soon.

@Peefy Peefy changed the title [Enhancement] Nix package [Enhancement] Nix package of KCL CLI and Language Server Apr 24, 2024
@Peefy Peefy reopened this Apr 24, 2024
@Peefy
Copy link
Contributor

Peefy commented Apr 24, 2024

I've opened the kcl-language-server nix package PR at NixOS/nixpkgs#306538

@selfuryon
Copy link

Hey! I tried to use kcl-cli from nixpkgs but failed:

$ nix shell nixpkgs#kcl-cli
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

$ cat main.k 
hello = "KCL"

$  kcl run main.k
Init kcl runtime failed, path:  /home/syakovlev/go
Tip: Have you used a binary version of KCL in your PATH that is not consistent with the KCL Go SDK? You can upgrade or reduce the KCL version or delete the KCL in your PATH
If not, you can run `rm -r /home/syakovlev/go/bin` to fix this issue
panic: unexpected EOF: stderr = Could not start dynamically linked executable: kclvm_cli
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld


goroutine 1 [running]:
kcl-lang.io/kcl-go/pkg/runtime.initRuntime(0xc00093f6d8?)
	kcl-lang.io/[email protected]/pkg/runtime/init.go:62 +0x42f
kcl-lang.io/kcl-go/pkg/runtime.GetRuntime.func1()
	kcl-lang.io/[email protected]/pkg/runtime/init.go:26 +0x15
sync.(*Once).doSlow(0x0?, 0x0?)
	sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	sync/once.go:65
kcl-lang.io/kcl-go/pkg/runtime.GetRuntime()
	kcl-lang.io/[email protected]/pkg/runtime/init.go:26 +0x2c
kcl-lang.io/kcl-go/pkg/service.NewKclvmServiceClient()
	kcl-lang.io/[email protected]/pkg/service/client_kclvm_service.go:21 +0x13
kcl-lang.io/kcl-go/pkg/kcl.runWithHooks({0xc00093f890, 0x0, 0x0}, {0x5cae350, 0x1, 0x1}, {0xc00093faa8, 0x1, 0x1})
	kcl-lang.io/[email protected]/pkg/kcl/api.go:477 +0x16e
kcl-lang.io/kcl-go/pkg/kcl.run(...)
	kcl-lang.io/[email protected]/pkg/kcl/api.go:486
kcl-lang.io/kcl-go/pkg/kcl.RunWithOpts({0xc00093faa8?, 0xc00093faa8?, 0xc00093fa58?})
	kcl-lang.io/[email protected]/pkg/kcl/api.go:373 +0x45
kcl-lang.io/kpm/pkg/api.RunWithOpt(0xc000b87200)
	kcl-lang.io/[email protected]/pkg/api/kpm_run.go:89 +0x36a
kcl-lang.io/cli/pkg/options.(*RunOptions).Run(0xc0008f80e0)
	kcl-lang.io/cli/pkg/options/run.go:126 +0x1e9
kcl-lang.io/cli/cmd/kcl/commands.NewRunCmd.func1(0xc00058c400?, {0xc0005a8990?, 0x4?, 0x2263e4c?})
	kcl-lang.io/cli/cmd/kcl/commands/run.go:49 +0x5a
github.com/spf13/cobra.(*Command).execute(0xc00015e908, {0xc0005a8950, 0x1, 0x1})
	github.com/spf13/[email protected]/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc00015e608)
	github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:1039
main.main()
	kcl-lang.io/cli/cmd/kcl/main.go:14 +0x1c

$ kcl version
0.8.6-linux-amd64

That means it isn't a full package of all needed binaries for using kcl, right? I also need kclvm_cli at least? Is it planned to package kclvm_cli too?

I'm a newbie at KCL, just wanted to compare it with CUE, but can't get it work on NixOS still.

@Peefy
Copy link
Contributor

Peefy commented Apr 30, 2024

Oh, it seems to conflict with the running mode of nix package management. You can use the download script to get the kcl cli. I will fix it later.

NixOS cannot run dynamically linked executables intended for generic linux environments out of the box. For more information, see: https://nix.dev/permalink/stub-ld

@diefans
Copy link

diefans commented Apr 30, 2024

@selfuryon you may try https://github.com/diefans/kcl-nix at least I fixed my problems...

@Peefy Peefy assigned He1pa and unassigned Peefy Jun 5, 2024
@aldoborrero
Copy link

We also need to provide the LSP, after PR nixpkgs#31827 is merged a separate PR will be prepared for tackling that.

@diefans
Copy link

diefans commented Jun 26, 2024

@aldoborrero I had problems building the LSP...

I was pointing sourceRoot = "source/kclvm/tools/src/LSP"; but got

error: Permission denied (os error 13) at path "/build/source/kclvm/targetlnQ0hp"

so to me it seems, that the build process wants to modify a "higher" directory, which nix prevents.... IMHO I am wondering, why you have all that tools not in separate repos/crates...

@aldoborrero
Copy link

aldoborrero commented Jun 26, 2024

@diefans have you tried using cargoBuildHooks? With that you don't need to point sourceRoot to that specific path (or it shouldn't be the case).

@Peefy Peefy unassigned He1pa Jun 28, 2024
@Peefy Peefy removed this from the v0.9.0 Release milestone Jul 1, 2024
@aldoborrero
Copy link

aldoborrero commented Jul 5, 2024

@diefans apologies for my late reply, but I have successfully compiled kcl-language-server version 0.9.0. You can have a look here. I'll port this to nixpkgs next week and I'll restore tests as those are commented for now.

@selfuryon I'm pinging you as well as you might be interested too.

@diefans
Copy link

diefans commented Jul 5, 2024

@aldoborrero I am also late ...swept away by too many projects, duties, life, etc... :) I was able to compile with your buildAndTestSubdir hint... but two tests were failing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed release
Projects
None yet
Development

No branches or pull requests

7 participants