Description
Is your feature request related to a problem?
Currently the way flakes handle ignored files (via a git repo) is confusing at best and actively detrimental at worst. I'm a brand new user to nixos, but I've been around computers for many years, and I'm finding the flake defaults to be very annoying to work with, and I know I'm not the only one.
My main issue is that I see no intuitive reason why the files copied over by nixos-rebuild switch --flake
would be affected by the existence git repo. It is, as another user pointed out, "spooky action at a distance", which makes it really hard to reason about what is actually happening and why. This behavior is documented at least, so it's findable, but it's still confusing.
Additionally it makes my personal use-case harder to achieve cleanly. I'd like to have one central source-of-truth config for all my system settings and installed packages, but still have a small local config file for some overrides (username, hostname, etc.). These overrides are extremely machine-specific and don't make sense (to me) to be committed in the repo. And I'm not the only one wanting to set things up this way. This user on the forum and the lovely individual who put up #6858 both are just as annoyed and confused by this as I am.
On the flip side, the git approach is also currently the only way to exclude files from being copied. So if someone has some secret file(s) they don't want included in the flake copy they currently have to make a git repo. This is also silly and confusing, and leads to issues like #9996.
Proposed solution
I propose using a clear and explicit hierarchy of .ignore
files to control which files do and don't get included in the flake copy, and ditching the git
integration entirely.
What I would like to see is the following hierarchy:
- If there is a
.nixignore
in the same directory as the running flake, then its contents (and exclusively its contents) are used to control which files are copied over to the system copy. - If there is no
.nixignore
, then it should check for a standard.ignore
file. - If neither
.nixignore
nor.ignore
is found, it should check for a.gitignore
- If none of these three files is found, then all files should be included. At no point should more than one of these files be used simultaneously. If multiple are found, only the first in the above list should be used.
Alternative solutions
An alternative solution is to go with the approach posed in #6858, but that still doesn't allow for having nix use files that are explicitly .gitignore
d. It also doesn't allow for ignoring files without using a git repo.
Additional context
N/A
Checklist
- checked latest Nix manual (source)
- checked open feature issues and pull requests for possible duplicates
Add 👍 to issues you find important.