From e716961d780b70295076f1b16f9174ea31273f2a Mon Sep 17 00:00:00 2001 From: Jacob Birkett Date: Sun, 5 Feb 2023 03:02:57 -0700 Subject: [PATCH] modules: java: fix setting JAVA_HOME (#3638) Some JVMs pass through `home` as a derivation rather than as a string, as `openjdk` does. Since the module option for session variables expects a string, this is a type error. I suspect that this incorrect, and have changed the assignment here to coerce the `cfg.package.home` attribute to a string to be safe. After discussing with @NobbZ, we have decided it is best to mitigate this problem in HM rather than to make potentially breaking changes to Nixpkgs. Please do mention if you think we ought to propose a change to Nixpkgs instead. --- modules/programs/java.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/programs/java.nix b/modules/programs/java.nix index 24467a255..d10f64c54 100644 --- a/modules/programs/java.nix +++ b/modules/programs/java.nix @@ -36,6 +36,8 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; - home.sessionVariables.JAVA_HOME = cfg.package.home; + # some instances of `jdk-linux-base.nix` pass through `result` without turning it onto a path-string. + # while I suspect this is incorrect, the documentation is unclear. + home.sessionVariables.JAVA_HOME = "${cfg.package.home}"; }; }