Skip to content

Commit

Permalink
modules: java: fix setting JAVA_HOME (#3638)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
spikespaz authored Feb 5, 2023
1 parent 2ffc6d6 commit e716961
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/programs/java.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
};
}

0 comments on commit e716961

Please sign in to comment.