How tightly are flakes tied to git repos?

I know git is the standard, and I know there are advantages to having flakes in a git repo. The reason I ask is, I prefer to use fossil rather than git for my personal repos. As far as I can tell, I would get the same benefit regardless of what VCS I use. I’d like to know if I’m wrong about that.

Also, this is coming from the perspective of a new NixOS/Nix user, using flakes for both system configuration and Home Manager configuration. I haven’t created flakes for custom software to be used by other people. For that, sticking with GitHub makes sense.

  • If I make changes to my config, I need to check it into the repo manually. nixos-rebuild has an option to checkin the lock file, but I don’t know if it does any automatic checkin for the actual nix files (I’ve yet to see it work). And Home Manager doesn’t seem to have any automatic checkin options. So either I manually checkin to git, or I manually checkin to fossil. Looks like the same result.
  • I’ve heard mention the benefit of a git repo being that Nix will only use files that are part of the repo, and ignore untracked files. Personally, I’ve yet to see the benefit of this. If a file exists in the same directory as your flake, why wouldn’t you include it? Either I’ve created a new file, and I need to add it to the repo, or I no longer want to use the file, and I delete it. I don’t see the benefit here (and I don’t shove tons of stuff into the same directory to warrant an extra layer of separation).
  • Pinning a particular repo commit. Is this something Nix does on its own? This may be more of a benefit when it comes to importing flake packages. For my own configurations, I’m either using the latest version, or I’m manually rolling back to a previous commit. Does Nix need to care?

Is there anything else I lose out on if I use a repo to track changes, but Nix just sees a directory of files (since it has no fossil support)?

1 Like

I think the first thing to get clearer here is the distinction between your flake (in the current working directory) and various dependencies (inputs) of your flake, such as nixpkgs, which are the things that get pinned according to their versioning scheme.

I don’t have answers for you regarding fossil in particular, but this at least makes whatever problems there might be smaller (just the first two points, and much more under your control).

1 Like