summary refs log tree commit diff
path: root/pkgs/applications/editors/emacs/elisp-packages/fetchelpa.nix
blob: f4524f3b7a95bb6db556fff2428d256950ad2360 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
  '';
})