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 its tracked.
Apparently I’m supposed to have it in the root of the git folder, but why does Nix require that? .config is tracked with git since those are my dotfiles, and I put my nix files in their own folder for organization, and it’s not a package. I don’t like how Nix tries to dictate the way I use git, with this plus not recognizing git-untracked files.
It’s because that’s the heuristic nix uses to determine what files to copy to the nix store. If your project directory is a git repo, it will use git to determine which files are tracked and copy those files to the nix store for reproducibility.
Since your nix directory is not a separare git repo, nix assumes that the parent directory is the project directory (it can’t make any other assumptions), and tries to treat that directory as a flake. The result is your error message.
This is one of the big problems with flakes, FWIW, that whole copying behavior is extremely silly and only copying stuff tracked by git is a workaround to make it slightly less silly. It potentially leaks secrets and wastes disk writes, for almost no benefit since builds are sandboxed anyway.
You can either try to override this behavior by using an explicit path URI (making the copy behavior even worse), make your nix directory a git submodule, or move the directory to somewhere it doesn’t have a parent git repo.
FWIW, making ~/.config a git repo is a bad idea, since various applications store (sometimes binary) data there. You can’t realistically track changes in that directory with git. I would recommend using either home-manager to properly deploy files into the directory or something like GNU stow if you really dislike home-manager for some reason.
Also ~/.config/nix is where your user’s nix configuration lives, putting your system config there is a bad idea.
Nix allows multiple flake.nix files in a single git repository, so if your flake.nix is not in the default location, please use --flake /home/user/.config/nix?dir=/path/to/flake.
That will work, but is not correct here, since ~/.config is not a flake. It will result in copying the entirety of ~/.config into /nix/store, which is certainly not what you want in this case.
You want --flake path:///home/user/.config/nix, but again, putting your system config there is inadvisable in the first place.
Thanks, that works for the command: nixos-option --flake path:///home/user/.config/nix services.atuin.enable.
The reasons you gave for not having it there is valid, though ideally I just dont want to have to conform propitiated choices like how to organize repos. Most of my software configuration is in .config by default which makes git tracking it a no brainer for me. I would only consider dotfiles managers if this turns out to be much more work, right now it isn’t, and adding folders to .gitignore is trivial.