Since IntelliJ keeps forgetting the JDK I set for a project, I was thinking: could I automatically link the latest jdk (meaning whatever I get when I nix-shell -p jdk) to a certain path? For example /opt/jdk or something?
For my user, I can certainly do nix-build -A jdk '<nixpkgs>' --out-link ~/jdk, but that doesn’t get updated as the system upgrades.
This gives 3 certain locations which correspond to <nixpkgs-booted>, <nixpkgs-current> and <nixpkgs-next>:
A NixOS module which creates the code for system.extraSystemBuilderCmds
The motivation to have a module is to gather requests for stable path from other modules.
For example, if another module needs jdk on stable path it can use system.stable.packages."myjdk" = jdk8 to land it at /run/current-system/pkgs/myjdk
instead of contributing to dll hell with environment.systemPackages = [ jdk8 ]
system.stable.selectors is for mass-matching, for example system.stable.selectors = [ "(open|oracle)jdk[0-9]+" ]; will make links for all JDK’s available in currently used nixpkgs (so these paths are not truly stable, upgrading nixpkgs could delete paths to deprecated JDKs)