1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

java: add module

This commit is contained in:
Shamrock Lee 2021-08-02 17:14:10 +08:00 committed by Robert Helgesson
parent a57ef9dad1
commit a4a8307897
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 56 additions and 0 deletions

2
.github/CODEOWNERS vendored
View file

@ -95,6 +95,8 @@
/modules/programs/i3status-rust.nix @workflow
/modules/programs/java.nix @ShamrockLee
/modules/programs/keychain.nix @marsam
/modules/programs/lazygit.nix @kalhauge

View file

@ -2157,6 +2157,13 @@ in
A new module is available: 'services.notify-osd'.
'';
}
{
time = "2021-08-10T21:28:40+00:00";
message = ''
A new module is available: 'programs.java'.
'';
}
];
};
}

View file

@ -77,6 +77,7 @@ let
./programs/i3status.nix
./programs/info.nix
./programs/irssi.nix
./programs/java.nix
./programs/jq.nix
./programs/kakoune.nix
./programs/keychain.nix

46
modules/programs/java.nix Normal file
View file

@ -0,0 +1,46 @@
# 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 = fileContents (pkgs.runCommandLocal "java-home" { } ''
source "${cfg.package}/nix-support/setup-hook"
echo "$JAVA_HOME" > $out
'');
};
};
}