I’d like to use vscode on NixOS with the ‘metals’ extension, which requires a JDK.
I was already successful in loading the Metals extension with:
environment.systemPackages = with pkgs; [
...
(vscode-with-extensions.override {
vscodeExtensions = with vscode-extensions; vscode-utils.extensionsFromVscodeMarketplace [
{
name = "metals";
publisher = "scalameta";
version = "1.5.7";
sha256 = "0n99gw1imnm2hbizxrwnbrk8sxz5ysbzll4hn3jqy1xv3ky1pkix";
}
{
name = "scala";
publisher = "scala-lang";
version = "0.3.8";
sha256 = "17dl10m3ayf57sqgil4mr9fjdm7i8gb5clrs227b768pp2d39ll9";
}
];
})
...
];
However, I’m running into trouble adding the JDK. I guess I want to do 2 things: register the JDK as a dependency, and also setting the JAVA_HOME environment variable so that the metals extension can actually find it.
So far I tried:
environment.systemPackages = with pkgs; [
...
(vscode-with-extensions.override {
vscode = vscode.overrideAttrs (oldAttrs: rec {
buildInputs = oldAttrs.buildInputs ++ [ jdk ];
JAVA_HOME = "${jdk}";
});
vscodeExtensions = with vscode-extensions; vscode-utils.extensionsFromVscodeMarketplace [
{
name = "metals";
publisher = "scalameta";
version = "1.5.7";
sha256 = "0n99gw1imnm2hbizxrwnbrk8sxz5ysbzll4hn3jqy1xv3ky1pkix";
}
{
name = "scala";
publisher = "scala-lang";
version = "0.3.8";
sha256 = "17dl10m3ayf57sqgil4mr9fjdm7i8gb5clrs227b768pp2d39ll9";
}
];
})
...
];
In /nix/store/3ci6gvxflqh36d00kpv84rvhahsg1q5y-vscode-1.38.1.drv
I do see
("JAVA_HOME","/nix/store/hna1lkls18hhr9hg2nrc0sgdjmxbv9cs-openjdk-8u222-ga")
but when I actually run code
I don’t see it in the environment.
What could I be missing?