Java: Difference between revisions
imported>Volth →Using Oracle JDK instead of Open JDK: use programs.java |
imported>Volth →Using Oracle JDK instead of Open JDK: requireFile helper |
||
| Line 41: | Line 41: | ||
programs.java = { enable = true; package = pkgs.oraclejre8; }; | programs.java = { enable = true; package = pkgs.oraclejre8; }; | ||
} | } | ||
</syntaxhighlight> | |||
Working with `requireFile` (manual downloading the tarballs and manual adding in to the nix store) might be annoying and nixops-unfriendly, so it can be overrides in overlays | |||
<syntaxhighlight lang="nix"> | |||
let | |||
files = { | |||
"jdk-8u241-linux-linux-arm32-vfp-hflt.tar.gz" = /home/user/blobs/java/jdk-8u241-linux-linux-arm32-vfp-hflt.tar.gz; | |||
"jdk-8u241-linux-linux-arm64-vfp-hflt.tar.gz" = /home/user/blobs/java/jdk-8u241-linux-linux-arm64-vfp-hflt.tar.gz; | |||
"jdk-8u241-linux-i586.tar.gz" = /home/user/blobs/java/jdk-8u241-linux-i586.tar.gz; | |||
"jdk-8u241-linux-x64.tar.gz" = /home/user/blobs/java/jdk-8u241-linux-x64.tar.gz; | |||
}; | |||
in | |||
nixpkgs.overlays = [ | |||
(self: super: { | |||
requireFile = args @ {name, url, sha1 ? null, sha256 ? null}: | |||
if files?${name} then | |||
self.stdenvNoCC.mkDerivation { | |||
inherit name; | |||
outputHashMode = "flat"; | |||
outputHashAlgo = if sha256 == null then "sha256" else "sha1"; | |||
outputHash = if sha256 == null then sha256 else sha1 ; | |||
buildCommand = "cp ${files.${name}} $out"; | |||
} | |||
else | |||
super.requireFile args; | |||
) | |||
]; | |||
</syntaxhighlight> | </syntaxhighlight> | ||