2024-08-28 06:36:28 +00:00
|
|
|
{ stdenvNoCC, lib, fetchzip, fetchurl, curl }:
|
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
{ id, file ? "", formats ? [ ], hash ? "", name ? "internet-archive-${id}",
|
2024-08-28 06:36:28 +00:00
|
|
|
}@args:
|
|
|
|
|
|
|
|
let
|
|
|
|
isFormatIndiciated = formats != [ ];
|
2025-01-12 09:57:14 +00:00
|
|
|
url = if isFormatIndiciated then
|
|
|
|
"https://archive.org/compress/${lib.escapeURL id}/formats=${
|
|
|
|
lib.concatStringsSep "," formats
|
|
|
|
}"
|
|
|
|
else
|
|
|
|
"https://archive.org/download/${lib.escapeURL id}/${lib.escapeURL file}";
|
2024-08-28 06:36:28 +00:00
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
args' = lib.removeAttrs args [ "id" "file" "formats" ] // {
|
|
|
|
inherit url hash name;
|
|
|
|
};
|
2024-08-28 06:36:28 +00:00
|
|
|
|
2025-01-12 09:57:14 +00:00
|
|
|
fetcher = if isFormatIndiciated then fetchzip else fetchurl;
|
|
|
|
in fetcher args'
|