Use two system packages versions side by side

I know that one of the strengths of NixOS is to allow running different versions of the same package. However, I cannot figure out how to do it for system packages.

For example, say that I have installed Julia 1.6 via:

environment.systemPackages = with pkgs; [

Now, Julia is available by running julia:

rik@nixos ~> julia -e 'println(VERSION)'

Can I now also get, for example, Julia 1.5, which is available as julia-stable and load that via something like:

rik@nixos ~> julia_stable -e 'println(VERSION)'

Would that mean adding a new derivation via stdenv.mkDerivation, or can I just override the command somewhere?

Recommended method is to use nix-shell (or nix shell when using experimental nix command).
With the latter it would be e.g.

$ nix shell nixpkgs/nixos-21.05#julia-stable

Note there is also the myEnvFun function with which you define an environment, install it, and then say load-env-<name> to open a shell with the environment. This isn’t really maintained/documented anymore.