mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 16:57:55 +00:00
28 lines
661 B
Nix
28 lines
661 B
Nix
{ stdenvNoCC, lib, fetchzip, fetchurl, curl }:
|
|
|
|
{
|
|
id,
|
|
file ? "",
|
|
formats ? [ ],
|
|
hash ? "",
|
|
name ? "internet-archive-${id}",
|
|
}@args:
|
|
|
|
let
|
|
isFormatIndiciated = formats != [ ];
|
|
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}";
|
|
|
|
args' = lib.removeAttrs args [ "id" "file" "formats" ] // {
|
|
inherit url hash name;
|
|
} // lib.optionalAttrs isFormatIndiciated { inherit hash; };
|
|
|
|
fetcher =
|
|
if isFormatIndiciated
|
|
then fetchzip
|
|
else fetchurl;
|
|
in
|
|
fetcher args'
|