Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callCabal2nix: Don't rebuild unchanged cabal file (Fixed #23880) #30751

Merged

Conversation

ElvishJerricco
Copy link
Contributor

Motivation for this change

#23880 caused #24245 and was reverted. This PR fixes the issue by only applying filterSource on sources of type path. I'm usually weary of these dynamically typed things, but I think it's worth it in this case. Editing haskell files should not result in the cabal file being reevaluated by cabal2nix, and it definitely shouldn't cause the entire source tree to be copied into the nix store.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@peti peti merged commit c47d77c into NixOS:master Oct 24, 2017
@PierreR
Copy link
Contributor

PierreR commented Dec 5, 2017

@ElvishJerricco what should I do when I do want to rebuild anytime I change the rev in

          package_latest = hsuper.callCabal2nix "language-puppet" (pkgs.fetchFromGitHub {
            owner  = "xxxxx";    repo   = "language-puppet";
            rev = "2845454bd0bc95771d875df273adc63e24ddaded";
            sha256 = "1iz5gflicris9jf5fvzfv8i69hmsr432dbv4hrpvqk0z1sqh0qbb";
          }) { };

This is actually quite a common workflow for me right now. I want to get the latest revision of a package in github but the cabal file is left unchanged because it is not released yet.

Is there an easy way to do that without removing the cached derivation ?

@ElvishJerricco
Copy link
Contributor Author

@PierreR That should work given this change no problem. Notice that it overrides the src field to put back the src argument; if that src is different, it will yield a different derivation, even if the cabal file is unchanged.

@PierreR
Copy link
Contributor

PierreR commented Dec 5, 2017

@ElvishJerricco I am using nix-shell -A project release.nix with release.nix

I was using a simple version of this before with an older pinned nixpkgs version and it did refresh. If you don't see anything that is obviously wrong in 'release.nix' I will check that with older version to be sure.

Thanks for your quick feedback.

@ElvishJerricco
Copy link
Contributor Author

@PierreR fetchFromGitHub is a fixed output derivation. If you don't change the sha256 argument, then any changes to the other arguments will not trigger a rebuild, even if such a rebuild would fail since the src hash is wrong. Notice that your nixpaste link contains a fetchFromGitHub expression that does not build. To test this, you can use --check, like nix-build release.nix -A language-puppet_latest.src --check, if you add language-puppet_latest to the release.nix output. The reason that you did not notice this is that you kept the sha256 from a different version that you had successfully built, which told Nix not to retry the src download, and just use the old one.

I think fetchFromGitHub used to not exhibit this behavior, and would get treated as a different derivation if only the rev changed and not the sha (which would fail), so that might be why this used to work for you.

TL;DR: This is fetchFromGitHub's fault, not callCabal2nix's. You need to update your sha256.

@vcunat
Copy link
Member

vcunat commented Dec 5, 2017

The typical hack is to make some random change in the hash.

@PierreR
Copy link
Contributor

PierreR commented Dec 5, 2017

@ElvishJerricco I wasn't aware about the change. Thanks for your valuable help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants