Load devShell from flake wherever I am

Hello.

The use case

I’d like to get the following workflow:
I declare all my devShells for the different languages (python, rust, etc.)
in my flake.nix and I’d like to switch to them wherever I’m for example by
executing

nix develop my_rust

where my_rust stands for the devShell configuration for rust in my
flake.nix.

What’s the problem?

I don’t want to add the path to my flake.nix all the time like

nix develop /a/ridiculous/long/path/to/my/flake.nix#rust

just to get my tools.

Solution ideas

So I’ve got the following ideas how to approach this, but I’m unsure if there’s maybe a more elegant way for achieving this:

  1. Create an environment-variable in my system-config which stores the absolute path to my flake.nix and then I “just” need to do nix develop $<ENV_VARIABLE_NAME>#<shell type>
  2. Create a shell function which has the absolute path hardcoded to my flake.nix which, obviously, has the disadvantage of being breakable if I move my flake.nix somewhere else.

Do you have any better ideas or is there an elegant way to achieve what I want?

I just got an answer on the NixOS (unofficial) discord server:
I can create an “alias” to my flake with nix registry and accessing my flake through an alias.