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:
- Create an environment-variable in my system-config which stores the absolute path to my
flake.nix
and then I “just” need to donix develop $<ENV_VARIABLE_NAME>#<shell type>
- 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 myflake.nix
somewhere else.
Do you have any better ideas or is there an elegant way to achieve what I want?