mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
fetchs3: support hash
attribute
This commit is contained in:
parent
b5aefcd40a
commit
1ccd5ba540
@ -1,15 +1,16 @@
|
||||
{ lib, runCommand, awscli }:
|
||||
lib.fetchers.withNormalizedHash { } (
|
||||
{ s3url
|
||||
, name ? builtins.baseNameOf s3url
|
||||
, outputHash
|
||||
, outputHashAlgo
|
||||
, region ? "us-east-1"
|
||||
, credentials ? null # Default to looking at local EC2 metadata service
|
||||
, recursiveHash ? false
|
||||
, postFetch ? null
|
||||
}:
|
||||
|
||||
{ s3url
|
||||
, name ? builtins.baseNameOf s3url
|
||||
, sha256
|
||||
, region ? "us-east-1"
|
||||
, credentials ? null # Default to looking at local EC2 metadata service
|
||||
, recursiveHash ? false
|
||||
, postFetch ? null
|
||||
}:
|
||||
|
||||
let
|
||||
let
|
||||
mkCredentials = { access_key_id, secret_access_key, session_token ? null }: {
|
||||
AWS_ACCESS_KEY_ID = access_key_id;
|
||||
AWS_SECRET_ACCESS_KEY = secret_access_key;
|
||||
@ -17,20 +18,20 @@ let
|
||||
};
|
||||
|
||||
credentialAttrs = lib.optionalAttrs (credentials != null) (mkCredentials credentials);
|
||||
in runCommand name ({
|
||||
in runCommand name ({
|
||||
nativeBuildInputs = [ awscli ];
|
||||
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = sha256;
|
||||
inherit outputHash outputHashAlgo;
|
||||
outputHashMode = if recursiveHash then "recursive" else "flat";
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
||||
AWS_DEFAULT_REGION = region;
|
||||
} // credentialAttrs) (if postFetch != null then ''
|
||||
} // credentialAttrs) (if postFetch != null then ''
|
||||
downloadedFile="$(mktemp)"
|
||||
aws s3 cp ${s3url} $downloadedFile
|
||||
${postFetch}
|
||||
'' else ''
|
||||
'' else ''
|
||||
aws s3 cp ${s3url} $out
|
||||
'')
|
||||
'')
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user