1 # This module provides JAVA_HOME, with a different way to install java
4 { config, lib, pkgs, ... }:
9 cfg = config.programs.java;
18 enable = mkEnableOption (lib.mdDoc "java") // {
19 description = lib.mdDoc ''
20 Install and setup the Java development kit.
23 This adds JAVA_HOME to the global environment, by sourcing the
24 jdk's setup-hook on shell init. It is equivalent to starting a shell
25 through 'nix-shell -p jdk', or roughly the following system-wide
28 environment.variables.JAVA_HOME = ''${pkgs.jdk.home}/lib/openjdk;
29 environment.systemPackages = [ pkgs.jdk ];
36 defaultText = literalExpression "pkgs.jdk";
37 description = lib.mdDoc ''
38 Java package to install. Typical values are pkgs.jdk or pkgs.jre.
47 config = mkIf cfg.enable {
49 environment.systemPackages = [ cfg.package ];
51 environment.shellInit = ''
52 test -e ${cfg.package}/nix-support/setup-hook && source ${cfg.package}/nix-support/setup-hook