Error: Path 'flake.nix' does not exist in Git repository "/home/user/.config"

When I do nixos-option --flake /home/user/.config/nix/ services.atuin.enable it outputs error: Path 'flake.nix' does not exist in Git repository "/home/user/.config". I stored my nix config files in .config/nix where flake.nix is, and I checked that its tracked.

It means you made ~/.config into a git repo, which you shouldn’t. And ~/.config/nix is the wrong place for your system config anyway, that’s where nix config goes.

Relocate your flake and ensure that the flake.nix is at the root of your git repo.

Why shouldn’t I make ~/.config a git repo?

Because electron apps dump their state there.

And wrt flakes your entire repo gets copied into the nix store on eval.

So if I do nixos-rebuild switch --flake ~/.config/nix where all the .nixare stored, and there’s a git repo in a parent folder, then it will copy that whole parent folder to /nix/store?

Yes, and as said, ~/.config/nix is the wrong place for your system config.

But why does Nix require the files to be in the root of the git repo?

Because nix (when using flakes in a git repo) makes certain assumptions that are not always accurate. I mean you could try using path: in front of the flake-url as a workaround to ignore the git repo, but keep in mind even untracked and hidden files will get copied to the store too.

wow someone doesn’t like flakes huh?

I don’t think that’s a reasonable conclusion to be drawn from someone offering both help and a factual analysis of how flakes are currently implemented.