Nix-build, a user .gitignore and haskell issue

I had an issue where having *.cabal in .gitignore[1] made nix-build -A plutus-playground.server (from plutus-apps fail due to there being “No cabal file found”. Regardless of whether having *.cabal in .gitignore is a good idea, I wonder how did the issue come about – is the nix-build process adding files and commiting to repositories while building, or is it filtering inputs based on user’s .gitignore file?

[1] because of using package.yaml everywhere. This is perhaps a practice that has swung back to including .cabal files too given that stack recommends it and cabal has gotten better.

Ignored files are not included in the build process. In 99.999% of cases it makes no sense.

In the case of the Plutus stuff, generally lib.cleanGit or something is used. In the case of flakes, Nix natively does this.


Right, but depending on the contents of my .gitignore is a little bit of a lottery, no? Users might add things there that they want to generally ignore, but that doesn’t necessarily match what the package authors ignored.

Can you please share exactly what you are trying and how?

Your users gitgnore should never be considered by any fetchers.

I essentially ran nix-build -A plutus-playground.server from within plutus-apps repo at commit 41149926c108c71831cfe8d244c83b0ee4bf5c8a.

Had had the issue for a while and hadn’t find any solutions, but today decided to start from a clean linux user – and there it did work! so started to iterate with comment things out from my configuration.nix and running nixos-rebuild until I found the line in .gitignore.

System: nixos-version is “22.05pre345234.b2737d4980a (Quokka)”, nix-build --version is “nix-build (Nix) 2.5.1”.

Are you referring to a global ignore file (core.excludesfile) or .git/info/exclude? Or just a regular .gitignore file in the repo?

Yes, it’s the one pointed to from my ~/.gitconfig’s core.excludesfile setting.