From fc1d419506000b7b6273d9aeac6b429b8f620009 Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Fri, 21 Jun 2024 13:00:22 -0500 Subject: [PATCH] Tweak download script --- .gitignore | 1 + .gitlab-ci.yml | 8 +------- cache.sh | 6 ++++++ flake.nix | 23 ++++++++--------------- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 5012c47..db1ffb1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ serial-output* grub.cfg isolinux.cfg Vagrantfile +.direnv # Generated distros distros/fedora/rawhide/*.hcl diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7255dd5..3356321 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,13 +70,7 @@ downloads: paths: - ./packer_config/ script: - - packer init sources - - bash cache.sh - - mc alias set storage "http://localhost:9000" root "$MINIO_SECRET" - - | - for f in cache/*; do - mc put "$f" "storage/isos/$f" - end + - nix run ".#cache" trigger: stage: trigger diff --git a/cache.sh b/cache.sh index dc42722..e389341 100755 --- a/cache.sh +++ b/cache.sh @@ -24,3 +24,9 @@ curl --parallel -L "${files[@]}" popd ls -lh cache/ + +mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" + +for f in cache/*; do + mc put "$f" "storage/isos/$f" +done diff --git a/flake.nix b/flake.nix index 6a17f39..463cf16 100644 --- a/flake.nix +++ b/flake.nix @@ -35,30 +35,23 @@ devshells.default = { # These commands will be shown in the motd that users read # upon entering the shell - commands = [ - ]; + commands = [ { + package = self'.packages.cache; + category = "utils"; + help = "Downloads ISO files and adds them to the S3 bucket"; + } ]; }; # This is not special, this is just flakes - packages = let - src = ./.; - in { + packages = { cache = pkgs.writeShellApplication { name = "cache-isos"; runtimeInputs = with pkgs; [ + curl minio-client packer ]; - text = let - #getIso = t: pkgs.runCommand "t.txt" { - #nativeInputs = [ pkgs.packer ]; - #} "echo var.iso.url | ${pkgs.packer}/bin/packer console -var-file=\"${t}\" -config-type=hcl2 ${src}/sources/"; - #isos = lib.attrsets.mapAttrsToList (t: builtins.readFile (getIso t)) templates; - #processIsos = builtins.concatStringsSep "\n" (builtins.map (i: "echo ${i}") isos); - in '' - packer init sources/ - rm -f cache/*latest* cache/*Rawhide* - ''; + text = builtins.readFile ./cache.sh; }; };