mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 19:49:45 +01:00
b3565b3447
The previous variant used IFD to generate the `JAVA_HOME` variable and relied on internal hooks of the `java` package, this failed for a user cross compiling their configuration. This PR changes that and uses the `home` attribute, as documented in the very last sentence of the https://nixos.org/manual/nixpkgs/stable/#sec-language-java chapter.
41 lines
936 B
Nix
41 lines
936 B
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 ];
|
|
|
|
home.sessionVariables.JAVA_HOME = cfg.package.home;
|
|
};
|
|
}
|