44 lines
916 B
Nix
44 lines
916 B
Nix
|
{ lib
|
||
|
, runCommand
|
||
|
, findutils
|
||
|
, gdown
|
||
|
}:
|
||
|
let
|
||
|
|
||
|
mkFetcher = mkCmd: {
|
||
|
name ? "source",
|
||
|
assert_exists ? [],
|
||
|
url,
|
||
|
hash ? lib.fakeHash,
|
||
|
preferLocalBuild ? true,
|
||
|
}: runCommand name {
|
||
|
outputHash = if hash == "" || hash == null then lib.fakeHash else hash;
|
||
|
outputHashAlgo = null;
|
||
|
outputHashMode = "recursive";
|
||
|
inherit preferLocalBuild;
|
||
|
passthru = { inherit url; };
|
||
|
} ''
|
||
|
cd $(mktemp -d)
|
||
|
${mkCmd url}
|
||
|
${lib.concatMapStringsSep "\n" (fname: ''
|
||
|
if ! test -s ${lib.escapeShellArg fname}; then
|
||
|
echo ERROR: file not found: ${lib.escapeShellArg fname}
|
||
|
echo Files found:
|
||
|
${findutils}/bin/find .
|
||
|
false
|
||
|
fi
|
||
|
'') assert_exists}
|
||
|
if test $(ls | wc -l) -gt 1; then
|
||
|
mkdir $out
|
||
|
fi
|
||
|
cp -v * $out
|
||
|
'';
|
||
|
|
||
|
in {
|
||
|
|
||
|
fetchFromDrive = mkFetcher (url:
|
||
|
"HOME=$(mktemp -d) ${gdown}/bin/gdown ${lib.escapeShellArg url}"
|
||
|
);
|
||
|
|
||
|
}
|