Cloudef / zig2nix

Flake for packaging, building and running Zig projects.
MIT License
81 stars 1 forks source link

request: Include zls in devShell #13

Closed will closed 4 months ago

will commented 4 months ago

Thanks for making this flake!

I was thinking that it'd be nice if zls was included in the devShell, or at least optionally. Especially since at the moment in nixpkgs zig is 0.13 but zls is stuck at 0.12.

will commented 4 months ago

I was able to add this to my own flake, so not having it isn't a blocker to me or anything. So I'm okay if you decide not to add zls to this project.

If anyone is searching and comes to this issue here is how to add zls to your flake:

diff --git a/flake.nix b/flake.nix
index fa18218..43512f9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,12 +2,14 @@
   description = "Zig project flake";

   inputs = {
+    zls.url = "github:zigtools/zls?ref=0.13.0";
     zig2nix.url = "github:Cloudef/zig2nix";
   };

-  outputs = { zig2nix, ... }: let
+  outputs = { zig2nix, zls, ... }: let
     flake-utils = zig2nix.inputs.flake-utils;
   in (flake-utils.lib.eachDefaultSystem (system: let
+      zlsPkg = zls.packages.${system}.default;
       # Zig flake helper
       # Check the flake.nix in zig2nix project for more options:
       # <https://github.com/Cloudef/zig2nix/blob/master/flake.nix>
@@ -79,6 +81,8 @@
       apps.zon2nix = env.app [env.zon2nix] "zon2nix \"$@\"";

       # nix develop
-      devShells.default = env.mkShell {};
+      devShells.default = env.mkShell {
+        nativeBuildInputs = [zlsPkg];
+      };
     }));
 }
Cloudef commented 4 months ago

I was thinking about zls integration, but i think having it in the project flake like you have done is the best way to go.

will commented 4 months ago

Ok thanks!