mirror of
https://github.com/nix-community/home-manager
synced 2024-12-28 20:59:47 +01:00
e716961d78
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.
43 lines
1.1 KiB
Nix
43 lines
1.1 KiB
Nix
# This module provides JAVA_HOME, with a different way to install java locally.
|
|
# This module is modified from the NixOS module `programs.java`
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.programs.java;
|
|
|
|
in {
|
|
meta.maintainers = with maintainers; [ ShamrockLee ];
|
|
|
|
options = {
|
|
programs.java = {
|
|
enable = mkEnableOption "" // {
|
|
description = ''
|
|
Install the Java development kit and set the <envar>JAVA_HOME</envar>
|
|
variable.
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.jdk;
|
|
defaultText = "pkgs.jdk";
|
|
description = ''
|
|
Java package to install. Typical values are
|
|
<literal>pkgs.jdk</literal> or <literal>pkgs.jre</literal>.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ cfg.package ];
|
|
|
|
# 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}";
|
|
};
|
|
}
|