nix-community / emacs2nix

Automatically generate Nix expressions for Emacs packages
GNU General Public License v3.0
29 stars 17 forks source link

Don't update package recipes if the hash is unchanged #26

Closed ttuegel closed 8 years ago

ttuegel commented 8 years ago

Package recipes don't always need to come from the latest version of the MELPA repository. If a recipe's hash hasn't changed, there's no need to update the Git ref. This leads to generating much larger diffs than necessary.

mdorman commented 8 years ago

I presume that any solution will need to retain the stateless quality of running emacs2nix---since otherwise that effectively ties minimal diff generation to one machine.

The only option that I can see would be to query the git repository for when the recipe was last modified, and use that change id to construct the URL. I suspect it means that anyone running the process would have to have a complete copy of the repo---no shallow clones allowed---but that doesn't seem like a problem.

Does that sound like a reasonable strategy to you, or did you have something else in mind? I make absolutely no promises about how fast it would be for me to implement, but I'm good with git, and decent with Haskell, and it's an interesting problem....

ttuegel commented 8 years ago

It's much simpler than that! emacs2nix takes the old package set as an input:

-- Roughly
emacs2nix :: PackageSet -> IO PackageSet

So, when we compute the hash of the recipe files (necessary for the fetchurl call on the Nix side), we only use the new Git SHA if the hash of that recipe file has changed, otherwise we keep the old one.