Tell git to track flake.nix but without adding it:
git add --intent-to-add flake.nix
Tell git to assume that flake.nix doesn’t have any changes:
git update-index --assume-unchanged flake.nix
This way you end up with a clean git status, but flake.nix still being tracked by git and therefore accessible to Nix. The only restriction is that you can’t do git operations which would modify/remove the flake.nix
There are a few variations possible here. Each of these is “I, as the user, want to interact with a project …”.
“… without modifying the existing repository”
“… using an alternate directory”
“… untracked by any git at all”
“… tracked by git in current repository”
While these are all possible, I’d like to trim them down and simplify to the bare minimum to make it easier to document and provide best-practice recommendations. My hesitance to recommend “intent-to-add” is that it uses a portion of git that is unfamiliar to most people and it is likely to put repos into unexpected states.
do I need to create a git repo in the project-flox directory? Does it need a remote URL?
which nix files need to remain in the project directory? Am I suppose to add them to .gitignore then?
which nix files should be in the project directory? Must they be committed locally?
But actually I am maybe overthinking this. I can create a project-flox directory with all the nix files, open a flox develop session there and navigate to the project directory to open an IDE or use cargo. That might be the simplest thing to do isn’t it?
The idea is to have no flox files in your original project.
As you say
This is what i was implying. Do all flox work in one repository, then in a flox develop environment change to your project.
The my-project-flox directory would need to be a git repository but does not necessarily need to be pushed to a remote server.
You can also just add your original project as e.g. git submodule of the project-flox repo .
Mind, as @tomberek mentioned there are several ways, each with their own annoyances.
I’ve been using this approach successfully before, when the original project is not ready to include the nix setup. Also, the whole of nixpkgs the core nix package set is based on this approach.