From f1738b6e646249b0492510f0c718a061b81538af Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Wed, 15 Mar 2023 10:50:57 +1000 Subject: [PATCH] tasks.py: add update-terraform --- tasks.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tasks.py b/tasks.py index 568b8ec..c4ceaba 100644 --- a/tasks.py +++ b/tasks.py @@ -198,6 +198,25 @@ def scan_age_keys(c, host): ) +@task +def update_terraform(c): + """ + Update terraform devshell flake + """ + with c.cd("terraform"): + c.run( + """ +system="$(nix eval --impure --raw --expr 'builtins.currentSystem')" +old="$(nix build --no-link --print-out-paths ".#devShells.${system}.default")" +nix flake update --commit-lock-file +new="$(nix build --no-link --print-out-paths ".#devShells.${system}.default")" +commit="$(git log --pretty=format:%B -1)" +diff="$(nix store diff-closures "${old}" "${new}" | awk -F ',' '/terraform/ && /→/ {print $1}')" +git commit --amend -m "${commit}" -m "Terraform updates:" -m "${diff}" +""" + ) + + @task def format_disks(c, hosts="", disks=""): """