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
|
||||
}:
|
||||
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
|
||||
, url ? ""
|
||||
, curlOpts ? ""
|
||||
, outputHash ? ""
|
||||
, outputHashAlgo ? ""
|
||||
, md5 ? ""
|
||||
, sha1 ? ""
|
||||
, sha256 ? ""
|
||||
, sha512 ? ""
|
||||
, meta ? {}
|
||||
, port ? "8080"
|
||||
, postFetch ? ""
|
||||
, preferLocalBuild ? true
|
||||
}:
|
||||
# New-style output content requirements.
|
||||
inherit outputHash outputHashAlgo;
|
||||
outputHashMode = "recursive";
|
||||
|
||||
let
|
||||
inherit curlOpts
|
||||
postFetch
|
||||
ipfs
|
||||
url
|
||||
port
|
||||
meta;
|
||||
|
||||
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 ];
|
||||
|
||||
# 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;
|
||||
}
|
||||
# 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 { };
|
||||
|
||||
fetchipfs = import ../build-support/fetchipfs {
|
||||
inherit curl stdenv;
|
||||
};
|
||||
fetchipfs = callPackage ../build-support/fetchipfs { };
|
||||
|
||||
fetchit = callPackage ../applications/networking/cluster/fetchit { };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user