Java: Difference between revisions
m Many people are struggling online to get started with Java on Nix using VSCode. This edit helps them get started quickly with VSCode. |
|||
Line 25: | Line 25: | ||
== VSCode + Language Support for Java (TM) by Red Hat extension == | == VSCode + Language Support for Java (TM) by Red Hat extension == | ||
Unfortunately the extension makes use of dynamically loaded libraries which nix cannot accomodate out-of-the-box. Fortunately there's a simple solution in the use of [https://github.com/Mic92/nix-ld nix-ld]. Here's a simple flake.nix to get you started (I'll focus on the devShell part for brevity): | Unfortunately the extension makes use of dynamically loaded libraries which nix cannot accomodate out-of-the-box. Fortunately there's a simple solution in the use of [https://github.com/Mic92/nix-ld nix-ld]. Here's a simple flake.nix to get you started (I'll focus on the devShell part for brevity): | ||
devShell = pkgs.mkShell { | devShell = pkgs.mkShell { | ||
Line 48: | Line 46: | ||
NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; # this needs .direnv:use flake --impure | NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker"; # this needs .direnv:use flake --impure | ||
}; | }; | ||
The important lines are the two lines starting with "NIX_LD...". They will let nix-ld wrap the required, dynamically loaded libraries so that they are found when building the devShell. | The important lines are the two lines starting with "NIX_LD...". They will let nix-ld wrap the required, dynamically loaded libraries so that they are found when building the devShell. |