mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
fetchipfs: simplify, error-out when given multiple hashes
Also dropped the `md5` attribute, as `stdenv.mkDerivation` rejects
MD5 since last year (87c22100a6
)
This commit is contained in:
parent
30361c578f
commit
7c19bb37a3
@ -1,50 +1,36 @@
|
|||||||
{ stdenv
|
{ lib
|
||||||
|
, stdenv
|
||||||
, curl
|
, curl
|
||||||
}:
|
}:
|
||||||
|
lib.fetchers.withNormalizedHash { hashTypes = [ "sha1" "sha256" "sha512" ]; } (
|
||||||
|
{ ipfs
|
||||||
|
, url ? ""
|
||||||
|
, curlOpts ? ""
|
||||||
|
, outputHash
|
||||||
|
, outputHashAlgo
|
||||||
|
, meta ? {}
|
||||||
|
, port ? "8080"
|
||||||
|
, postFetch ? ""
|
||||||
|
, preferLocalBuild ? true
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = ipfs;
|
||||||
|
builder = ./builder.sh;
|
||||||
|
nativeBuildInputs = [ curl ];
|
||||||
|
|
||||||
{ ipfs
|
# New-style output content requirements.
|
||||||
, url ? ""
|
inherit outputHash outputHashAlgo;
|
||||||
, curlOpts ? ""
|
outputHashMode = "recursive";
|
||||||
, outputHash ? ""
|
|
||||||
, outputHashAlgo ? ""
|
|
||||||
, md5 ? ""
|
|
||||||
, sha1 ? ""
|
|
||||||
, sha256 ? ""
|
|
||||||
, sha512 ? ""
|
|
||||||
, meta ? {}
|
|
||||||
, port ? "8080"
|
|
||||||
, postFetch ? ""
|
|
||||||
, preferLocalBuild ? true
|
|
||||||
}:
|
|
||||||
|
|
||||||
let
|
inherit curlOpts
|
||||||
|
postFetch
|
||||||
|
ipfs
|
||||||
|
url
|
||||||
|
port
|
||||||
|
meta;
|
||||||
|
|
||||||
hasHash = (outputHash != "" && outputHashAlgo != "")
|
# Doing the download on a remote machine just duplicates network
|
||||||
|| md5 != "" || sha1 != "" || sha256 != "" || sha512 != "";
|
# traffic, so don't do that.
|
||||||
|
inherit preferLocalBuild;
|
||||||
in
|
}
|
||||||
|
)
|
||||||
if (!hasHash) then throw "Specify sha for fetchipfs fixed-output derivation" else stdenv.mkDerivation {
|
|
||||||
name = ipfs;
|
|
||||||
builder = ./builder.sh;
|
|
||||||
nativeBuildInputs = [ curl ];
|
|
||||||
|
|
||||||
# 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" else "md5";
|
|
||||||
outputHash = if outputHash != "" then outputHash else
|
|
||||||
if sha512 != "" then sha512 else if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
|
|
||||||
|
|
||||||
outputHashMode = "recursive";
|
|
||||||
|
|
||||||
inherit curlOpts
|
|
||||||
postFetch
|
|
||||||
ipfs
|
|
||||||
url
|
|
||||||
port
|
|
||||||
meta;
|
|
||||||
|
|
||||||
# Doing the download on a remote machine just duplicates network
|
|
||||||
# traffic, so don't do that.
|
|
||||||
inherit preferLocalBuild;
|
|
||||||
}
|
|
||||||
|
@ -1141,9 +1141,7 @@ with pkgs;
|
|||||||
|
|
||||||
fetchRepoProject = callPackage ../build-support/fetchrepoproject { };
|
fetchRepoProject = callPackage ../build-support/fetchrepoproject { };
|
||||||
|
|
||||||
fetchipfs = import ../build-support/fetchipfs {
|
fetchipfs = callPackage ../build-support/fetchipfs { };
|
||||||
inherit curl stdenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchit = callPackage ../applications/networking/cluster/fetchit { };
|
fetchit = callPackage ../applications/networking/cluster/fetchit { };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user