From 66966119f34333f7a742f42fefba1b973c876657 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 6 Aug 2021 16:25:38 -0500 Subject: [PATCH 1/2] emacs: Add custom elpa fetcher Elpa only serves the latest version of a given package uncompressed. Once that release is no longer the latest & greatest it gets archived and compressed meaning that both the URL and the hash changes. To work around this issue we fall back to the URL with the .lz suffix and if that's the one we downloaded we uncompress the file to ensure the hash matches regardless of compression. --- .../emacs/elisp-packages/fetchelpa.nix | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pkgs/applications/editors/emacs/elisp-packages/fetchelpa.nix diff --git a/pkgs/applications/editors/emacs/elisp-packages/fetchelpa.nix b/pkgs/applications/editors/emacs/elisp-packages/fetchelpa.nix new file mode 100644 index 00000000000..f4524f3b7a9 --- /dev/null +++ b/pkgs/applications/editors/emacs/elisp-packages/fetchelpa.nix @@ -0,0 +1,21 @@ +# Elpa only serves the latest version of a given package uncompressed. +# Once that release is no longer the latest & greatest it gets archived and compressed +# meaning that both the URL and the hash changes. +# +# To work around this issue we fall back to the URL with the .lz suffix and if that's the +# one we downloaded we uncompress the file to ensure the hash matches regardless of compression. + +{ fetchurl, lzip }: + +{ url, ... }@args: fetchurl ((removeAttrs args [ "url" ]) // { + urls = [ + url + (url + ".lz") + ]; + postFetch = '' + if [[ $url == *.lz ]]; then + ${lzip}/bin/lzip -c -d $out > uncompressed + mv uncompressed $out + fi + ''; +}) From 6a5fc6becadc086f548582e513edd7b7c07dcda6 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 6 Aug 2021 16:26:09 -0500 Subject: [PATCH 2/2] emacs.pkgs.elpaPackages: Use custom elpa fetcher --- .../editors/emacs/elisp-packages/elpa-packages.nix | 7 +++++-- pkgs/top-level/emacs-packages.nix | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix b/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix index 02a9a6e6562..0b8929d5127 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/elpa-packages.nix @@ -21,7 +21,7 @@ formats commits for you. */ -{ lib, stdenv, texinfo, writeText }: +{ lib, stdenv, buildPackages, texinfo, writeText }: self: let @@ -41,7 +41,10 @@ self: let }: let imported = import generated { - inherit (self) callPackage; + callPackage = pkgs: args: self.callPackage pkgs (args // { + # Use custom elpa url fetcher with fallback/uncompress + fetchurl = buildPackages.callPackage ./fetchelpa.nix { }; + }); }; super = removeAttrs imported [ "dash" ]; diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index d168d34e373..c682a9da014 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -26,7 +26,7 @@ let mkElpaPackages = { pkgs, lib }: import ../applications/editors/emacs/elisp-packages/elpa-packages.nix { - inherit (pkgs) stdenv texinfo writeText; + inherit (pkgs) stdenv texinfo writeText buildPackages; inherit lib; };