Apply nixfmt to the whole tree
This commit is contained in:
+40
-37
@@ -1,44 +1,47 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
active,
|
||||
distroFile,
|
||||
writeShellApplication,
|
||||
active,
|
||||
distroFile,
|
||||
|
||||
curl,
|
||||
minio-client,
|
||||
packer,
|
||||
curl,
|
||||
minio-client,
|
||||
packer,
|
||||
|
||||
...
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (builtins) concatStringsSep map;
|
||||
in writeShellApplication {
|
||||
name = "cache-isos";
|
||||
runtimeInputs = [
|
||||
curl
|
||||
minio-client
|
||||
packer
|
||||
];
|
||||
text = ''
|
||||
push="''${1:-yes}"
|
||||
if [ "$push" == "yes" ]; then
|
||||
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
|
||||
fi
|
||||
mkdir -p cache
|
||||
'' + (concatStringsSep "\n" (
|
||||
map (d: ''
|
||||
url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
# shellcheck disable=SC2143
|
||||
if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then
|
||||
curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url"
|
||||
if [ "$push" == "yes" ]; then
|
||||
mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso"
|
||||
fi
|
||||
else
|
||||
echo "Skipping ${d.distro} - cache/$sha.iso"
|
||||
fi
|
||||
'') active
|
||||
));
|
||||
inherit (builtins) concatStringsSep map;
|
||||
in
|
||||
writeShellApplication {
|
||||
name = "cache-isos";
|
||||
runtimeInputs = [
|
||||
curl
|
||||
minio-client
|
||||
packer
|
||||
];
|
||||
text =
|
||||
''
|
||||
push="''${1:-yes}"
|
||||
if [ "$push" == "yes" ]; then
|
||||
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
|
||||
fi
|
||||
mkdir -p cache
|
||||
''
|
||||
+ (concatStringsSep "\n" (
|
||||
map (d: ''
|
||||
url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
|
||||
# shellcheck disable=SC2143
|
||||
if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then
|
||||
curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url"
|
||||
if [ "$push" == "yes" ]; then
|
||||
mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso"
|
||||
fi
|
||||
else
|
||||
echo "Skipping ${d.distro} - cache/$sha.iso"
|
||||
fi
|
||||
'') active
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user