core/pkgs/build-support/fetchipfs/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
1.3 KiB
Nix
Raw Normal View History

2024-05-02 00:46:19 +00:00
{ stdenv, curl }:
{
ipfs,
url ? "",
curlOpts ? "",
outputHash ? "",
outputHashAlgo ? "",
md5 ? "",
sha1 ? "",
sha256 ? "",
sha512 ? "",
meta ? { },
port ? "8080",
postFetch ? "",
preferLocalBuild ? true,
}:
let
hasHash =
(outputHash != "" && outputHashAlgo != "")
|| md5 != ""
|| sha1 != ""
|| sha256 != ""
|| sha512 != "";
in
if (!hasHash) then
throw "Specify sha for fetchipfs fixed-output derivation"
else
stdenv.mkDerivation {
name = ipfs;
builder = ./builder.sh;
nativeBuildInputs = [ curl ];
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
# New-style output content requirements.
outputHashAlgo =
if outputHashAlgo != "" then
outputHashAlgo
else if sha512 != "" then
"sha512"
else if sha256 != "" then
"sha256"
else if sha1 != "" then
"sha1"
2024-06-30 08:16:52 +00:00
else
2024-05-02 00:46:19 +00:00
"md5";
outputHash =
if outputHash != "" then
outputHash
else if sha512 != "" then
sha512
else if sha256 != "" then
sha256
else if sha1 != "" then
sha1
2024-06-30 08:16:52 +00:00
else
2024-05-02 00:46:19 +00:00
md5;
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
outputHashMode = "recursive";
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
inherit
curlOpts
postFetch
ipfs
url
port
meta
;
2024-06-30 08:16:52 +00:00
2024-05-02 00:46:19 +00:00
# Doing the download on a remote machine just duplicates network
# traffic, so don't do that.
inherit preferLocalBuild;
}