Merge pull request #135549 from Prillan/emacs-elpa-fetcher

emacs: Add custom elpa fetcher (backport)
This commit is contained in:
adisbladis 2021-08-24 10:42:17 -05:00 committed by GitHub
commit 3b049d720a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View File

@ -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" ];

View File

@ -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
'';
})

View File

@ -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;
};