fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.1 KiB43 linesraw
1# This module provides JAVA_HOME, with a different way to install java locally.
2# This module is modified from the NixOS module `programs.java`
3
4{ config, lib, pkgs, ... }:
5
6with lib;
7
8let
9
10  cfg = config.programs.java;
11
12in {
13  meta.maintainers = with maintainers; [ ShamrockLee ];
14
15  options = {
16    programs.java = {
17      enable = mkEnableOption "" // {
18        description = ''
19          Install the Java development kit and set the
20          {env}`JAVA_HOME` variable.
21        '';
22      };
23
24      package = mkOption {
25        type = types.package;
26        default = pkgs.jdk;
27        defaultText = "pkgs.jdk";
28        description = ''
29          Java package to install. Typical values are
30          `pkgs.jdk` or `pkgs.jre`.
31        '';
32      };
33    };
34  };
35
36  config = mkIf cfg.enable {
37    home.packages = [ cfg.package ];
38
39    # some instances of `jdk-linux-base.nix` pass through `result` without turning it onto a path-string.
40    # while I suspect this is incorrect, the documentation is unclear.
41    home.sessionVariables.JAVA_HOME = "${cfg.package.home}";
42  };
43}