Recently there was a fix regarding the implementation of fetchgit inside of nixpkgs: Instead of removing every single file that starts with .git, it will now only remove the folder .git. This way files like .gitignore will become part of the sources.
As a side effect, the hashes of the generated outputs will change. This is not a problem as long as you don't have to support the old and the new version of fetchgit simultaneously.
Use (abuse) a hook to restore the old behavior
One option which I found to support both variants at the same time is to exploit an existing hook inside of fetchgit.
The following snippet shows the definition which worked for me:
backwardsCompatibleFetchgit = { ... }@args: let origSources = pkgs.fetchgit args; in pkgs.lib.overrideDerivation origSources (oldAttrs: { NIX_PREFETCH_GIT_CHECKOUT_HOOK = '' find $out -name '.git*' -print0 | xargs -0 rm -rf ''; });
This basically restores the old and wrong behavior. Most probably it can be used as a tool to support both versions at the same time until support for the old version eventually can be dropped from the project.
Final thoughts
Although this approach does the trick, I think it would be nicer to import fetchgit from the old variant of nixpkgs and use it. This would probably work without using any special tweaks. It should be possible to achieve this based on fetchurl to fetch a specific version of nixpkgs.
Comments
comments powered by Disqus