Initial commit
This commit is contained in:
43
pkgs/fetchers.nix
Normal file
43
pkgs/fetchers.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{ 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}"
|
||||
);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user