Passing a `gitConfigFile` argument as a string allows setting a custom
git config (as `$GIT_CONFIG_GLOBAL`). The most obvious use is to
override URLs with custom mirrors, but others are possible too.
Adds a new argument to `nix-prefetch-git`: `--no-add-path`. It disables
adding the path to the store. It is useful when working with a read-only
store.
With this argument fetchgit will make a subdirectory of the Git
repository a root of the resulting store path. This is helpful for
dealing with monorepos where many projects are in separate directories
and don't need a new source hash every time the monorepo is updated.
Commit hash is removed from the name of the derivation to prevent it
from changing the store path when nothing in the subdirectory changes.
Added fetchTags feature to fetchgit, explicit and clear support for
fetching all tags after the source tree fetch completes. Doing this at
build-time in the fetcher is required for packages that invoke commands
like 'git describe' which require tags, and since the nix store is
read-only by design, it is not possible to git fetch --tags at
activation- or run-time. This feature may have been possible by
specifying a postFetch option including calling git fetch --tags,
however doing so obfuscates the solution to this very real problem.
Explicit support for fetching tags should be a first class citizen just
like fetching other refs.
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
Git v2.49.0 added support for using the faster zlib-ng library, and
benchmarks by GitLab show it's notably faster, so use it for our builds
too.
The different zlib implementation does change the contents of the .git
directory, which means the hashes for fetchgit tests that leave the .git
directory in place are expected to change.
https://about.gitlab.com/blog/2025/03/14/whats-new-in-git-2-49-0/#introduction-of-zlib-ng
The deepClone argument to fetchgit implies leaveDotGit. Make the
"submodule-deep" fetchgit test more useful by having it remove the .git
directory, as recommended in the fetchgit documentation, so it is
distinguished from the "submodule-leave-git-deep" test.
This version change includes a change to the contents of the .git
directory, which results in changes to hashes for any fetchgit
invocations that set leaveDotGit to true. Per the fetchgit
documentation and discussions in #372784, the contents of the .git directory are not stable, so
anyone using that should either only be using it for temporary testing
purposes, or should be removing the .git directory in fetchgit's
postFetch phase, so before the hash is calculated. That means there's
no need to do any other handling here to avoid compatibility problems,
and can just update the relevant hashes in the fetchgit tests.
There's still a chance this will break some other builds because of the
change to the contents of the .git directory. If so, whoever's
responsible for those other derivations should either stop using
leaveDotGit, or should follow the documented advice to remove the .git
directory in the postFetch phase.
The `sparseCheckout` argument allows the user to specify directories or
patterns of files, which Git uses to filter files it should check-out.
Git expects a multi-line string on stdin ("newline-delimited list", see
`git-sparse-checkout(1)`), but within nixpkgs it is more consistent to
use a list of strings instead. The list elements are joined to a
multi-line string only before passing it to the builder script.
A deprecation warning is emitted if a (multi-line) string is passed to
`sparseCheckout`, but for the time being it is still accepted.