Files
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

60 lines
1.2 KiB
Nix

{
lib,
runCommand,
awscli,
}:
lib.fetchers.withNormalizedHash { } (
{
s3url,
name ? baseNameOf s3url,
outputHash,
outputHashAlgo,
region ? "us-east-1",
credentials ? null, # Default to looking at local EC2 metadata service
recursiveHash ? false,
postFetch ? null,
}:
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;
AWS_SESSION_TOKEN = session_token;
};
credentialAttrs = lib.optionalAttrs (credentials != null) (mkCredentials credentials);
in
runCommand name
(
{
nativeBuildInputs = [ awscli ];
inherit outputHash outputHashAlgo;
outputHashMode = if recursiveHash then "recursive" else "flat";
preferLocalBuild = true;
AWS_DEFAULT_REGION = region;
}
// credentialAttrs
)
(
if postFetch != null then
''
downloadedFile="$(mktemp)"
aws s3 cp ${s3url} $downloadedFile
${postFetch}
''
else
''
aws s3 cp ${s3url} $out
''
)
)