You could pair @7c6f434c’s suggestion with Git worktrees which allow you to branch off in a different directory, which in this case can be one level deeper!
So, in theory, you could have the main branch having your dev setup, committed or not doesn’t really matter, enter nix develop (or use direnv), and then spin up a worktree in a directory one level deeper and have everything setup neatly.
Full disclosure, I haven’t used Git worktrees much myself, so I’m not sure if this works; but from my limited understanding of them, I think this can be a solid approach. I’ll try it out myself sometime soon.
Git worktrees are in principle a viable approach, maybe even the only morally correct one, but you’ll likely have to duct-tape together lots of helper tools to manage them fluently because it’s still just strings in files, and Git UX is meh.
Untested thought: would git subtrees work here? You could just create a new repo and then vendor the repo you want to contribute to in a subdirectory. The parent directory could contain the flake.nix. And then you have a nice UX to push back commits to that subdirectory.
I usually create shell.nix + .envrc files in the same repo and ignore them locally only in that project
echo ".envrc\nshell.nix" >> .git/info/exclude
The only reason I never used flake.nix in these situations was because it had to be tracked and I didn’t know about the git add --intent-to-add shared by @GetPsyched, so I will probably give this a try and see.
Worktrees should also work, I use them sometimes in large repos/projects but I find them a bit of an overkill for smaller repos/projects. This is clearly subjective, but it should work fine.
Reviving this topic after a bit of time, the way I am doing it is the following, tremendously trivial:
I have a master-nix where I store all the *.nix files.
I run nix develop --profile nix-env while on master-nix branch.
And have a nix-env profile where I can just nix develop nix-env into it and run tmux so that I have the same dev environment across all tmux windows and not having it tracked so that I can work on any branch, make PRs from it, and so on.
How do you Nixers rate my final approach? For me it’s really cool and simple