Using jj with a flake.nix
is a bad experience
#3970
Replies: 5 comments 24 replies
-
This seems painful, sorry. I'll ping @necauqua @thoughtpolice in case they have some advice. I'm guessing that the following is the problem's cause. In colocated repos, If the parent of the working copy is a conflicted commit, then it's stored in Git in a jj-specific way that non-jj-aware tools will not be able to understand. (It basically stores several versions of the repo in one commit, with a top-level dir for each version). So, as Nix tries to read the HEAD commit's contents with plain Git, it fails to find I'm not sure whether Boom, bad things happen. (Hopefully, I've just rephrased what you said into what I think is slightly more correct language. I don't think the words "staged" and "tracked/untracked" are correct here. I'm not sure what we can do to help. The ideal outcome (apart from Nix flakes being redesigned to have an option to not expect or require a Git repo) would be if Nix treated If you use a non-colocated repo, these specific problems will also not occur, as Nix will think the flake is not under version control. I think this cause Nix flakes to refuse to work in many cases. Specifying In principle, |
Beta Was this translation helpful? Give feedback.
-
By the way, nix-direnv at least falls back to the previous environment on failure these days. Although that has its own pitfalls. |
Beta Was this translation helpful? Give feedback.
-
Um, do you mean that you are in a conflicted state, and instead of the conflict being materialized, the sides are put into those top-level folders?. I can't reproduce your entire situation (checked out commit is conflicted -> flake.nix is untracked) in my head atm In my head, you check out a conflicted commit - the conflicts get materialized, and if they're not in flake.nix itself - it looks like an unchanged file that's committed and everything works, how does flake.nix (or the rest of your stuff) become untracked.. |
Beta Was this translation helpful? Give feedback.
-
This happens when you use git to check out a commit with conflicts. Use jj instead. |
Beta Was this translation helpful? Give feedback.
-
Sorry I don’t have time for a thorough response to all the sub-threads. As a user of Nix myself, I would love to see this resolved. My 2¢: Maybe the internal representation of conflicted commits in the Git backend of jj should change, to make it more friendly towards the colocated use case? I can think of a few ideas how to do that, but maybe a proper issue/PR would be a better place for them. |
Beta Was this translation helpful? Give feedback.
-
Nix flakes are used for auto-installing things. Often it is used with direnv. JJ itself uses this setup.
Nix flakes also require you to stage all the
.nix
files in git for them to be found. I think this is a problem with Nix itself -- what the hell sort of requirement is that? Ridiculous. But nevertheless JJ wrecks Nix setups when you have active conflicts.flake.nix
is an untracked file. Along with the rest of your stuff.jj
using your flake.nix (!)It would be nice if this were better. Anyone got a workaround?
Beta Was this translation helpful? Give feedback.
All reactions