From 3c496d2244b97846073a286ae5321abfb3b9a8fd Mon Sep 17 00:00:00 2001 From: adisbladis Date: Fri, 6 Aug 2021 16:25:38 -0500 Subject: [PATCH] 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 000000000000..f4524f3b7a95 --- /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 + ''; +})