flake.nix
lets you place dependencies in a dev shell:
{
...
outputs = {
...
devShells.default = pkgs.mkShell {
packages = [
pkgs.sometool
];
};
};
}
But there are often “dependencies” that don’t belong there (soft dependencies, we’ll call them). For instance, you wouldn’t add language servers there because different dev’s are likely to prefer different dev environments–so it’s not polite to enforce yours as a strict dependency.
Because of this, we leave it to each dev to configure that stuff, so maybe it ends up in ~/.config/nixpkgs/home.nix
or some such place. The problem I’m trying to solve is that when somebody asks “Hey, how do you have your dev env configured?” sending them to my home.nix
is too much info. They’ll find tools for a variety of projects in a variety of languages, plus remnants of failed experiments and other weird things.
I’d rather send them to something small and focused. For instance if it’s a python project, then I’d like to send them to a flake.nix that contains only the tools that I like to use for python development.
So my question is: Is there a recommended way to put “these are my favoried python tools” and “these are the tools for specifically this project” in separate flakes and still have them both be available in the devShell, while also keeping them separate from the system config?
I’ve found that I can create .envrc
files (for use with direnv) like this:
# ~/src/somepythonproj/.envrc
source_env_if_exists ~/dev/python/.envrc
use flake
Which seems to work ok: it lets me have a separate flake for soft dependencies and yet still have everything together in one shell while I’m developing, and without mixing together configs for separate ecosystems. But I want to know if I’m reinventing a wheel before I continue with the reinventing.
Thanks.