Using Oracle JDK with Nix package manager

0

Can somebody point me to the correct steps to install Oracle JDK with Nix package manager? I tried the following so far:

  1. https://nixos.org/nixos/packages.html#jdk - oracle is not there
  2. nix-env -i oraclejdk - package not found
  3. nix-env -qaP|grep oracle - no jdk
  4. https://nixos.wiki/wiki/Java - has no effect
  5. https://nixos.wiki/wiki/FAQ/How_can_I_install_a_proprietary_or_unfree_package%3F - has no effect

I did Nix multi user install on Debian as described here: https://nixos.org/nix/manual/#chap-installation. I did not change any configuration, and installation appears to be working fine (e.g. I can install scala, but it uses openjdk). My channels:

> nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable

Thank you.

qsd

Posted 2019-06-25T00:22:40.603

Reputation: 1

Where are you getting the package from? – fixer1234 – 2019-06-25T00:51:01.683

I assumed it's expected to be in the "default" channel added by the installer - a lot of the instructions say that it's supposed to appear once you enable unfree packages, and it is available in GitHub repo. Am I supposed to get it from somewhere else?

– qsd – 2019-06-26T05:07:10.493

You need to get it from somewhere. The question lists all the places where it isn't. You need to find a place where it is, and get it. – fixer1234 – 2019-06-26T05:24:52.180

Do you know where I can get it? – qsd – 2019-06-28T04:53:47.420

Unfortunately, not a clue. – fixer1234 – 2019-06-28T04:59:48.383

Answers

0

Running nix-env -i oraclejdk works for me on nixos-19.03 as well as on nixos-unstable. Is your nix-channel up to date?

For veryifing that you use the nixos-19.03 channel you can run

$ nix-channel --list
nixos-19.03 https://nixos.org/channels/nixos-19.03

To make sure, that you have the latest package expressions of your channel run

$ nix-channel --update

For migrating from an older channel you can run something like

$ nix-channel --list
nixos-17.09 https://nixos.org/channels/nixos-17.09

$ nix-channel --remove nixos-17.09

$ nix-channel --add https://nixos.org/channels/nixos-19.03 nixos-19.03

$ nix-channel --list
nixos-19.03 https://nixos.org/channels/nixos-19.03

$ nix-channel --update

For more information regarding channels see the docs.

erictapen

Posted 2019-06-25T00:22:40.603

Reputation: 36

That is very interesting - I already had unstable channel but not that package. I tried adding 19.03 channel as per your instructions, but the oraclejdk still didn't show up. I updated the question with the output of nix-channel. Are you using actual NixOS, or just the package manager? I am starting to suspect that there is a difference between the two. – qsd – 2019-07-01T16:05:27.783

Sorry for the late reply. Yes, I'm using NixOS, but there should be no difference in regard to the set of available packages. If you are still on it; Could you add the content of ~/.config/nixpkgs/config.nix and the value of $NIX_PATH to your answer? Also you could run nix build nixpkgs.oraclejdk and see, wether it results in a warning message about their license or if it just says, that the attribute couldn't be found? – erictapen – 2019-09-30T14:10:09.190

I looked into this again, and it looks like oraclejdk can only be referenced using attribute name, not package name. I.e. both nix build nixpkgs.oraclejdk and nix-env -iA nixpkgs.oraclejdk work, but nix-env -i oraclejdk does not. It's somewhat confusing, but good enough. Thanks for your help! – qsd – 2019-12-31T21:32:22.967