2021-08-02 11:14:10 +02:00
|
|
|
# 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 = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "" // {
|
|
|
|
description = ''
|
2023-07-01 09:48:09 +02:00
|
|
|
Install the Java development kit and set the
|
|
|
|
{env}`JAVA_HOME` variable.
|
2021-08-02 11:14:10 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.jdk;
|
|
|
|
defaultText = "pkgs.jdk";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-08-02 11:14:10 +02:00
|
|
|
Java package to install. Typical values are
|
2023-07-01 01:30:13 +02:00
|
|
|
`pkgs.jdk` or `pkgs.jre`.
|
2021-08-02 11:14:10 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
2023-02-05 11:02:57 +01:00
|
|
|
# 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}";
|
2021-08-02 11:14:10 +02:00
|
|
|
};
|
|
|
|
}
|