Apply nixfmt to the whole tree

This commit is contained in:
Greg Hellings
2024-11-18 21:22:32 -06:00
parent 18b7cddaaa
commit e7d1b0f7bd
34 changed files with 822 additions and 714 deletions
+40 -37
View File
@@ -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
));
}