From 3e63fa279f035df1d3650aa392f3a55a374e4cb4 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Fri, 9 Sep 2022 11:25:31 +1000 Subject: [PATCH] terraform-providers: add passthru.updateScript - drop nix-shell nixpkgs path --- .../networking/cluster/terraform-providers/default.nix | 8 +++++++- .../cluster/terraform-providers/update-all-providers | 2 +- .../cluster/terraform-providers/update-provider | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/cluster/terraform-providers/default.nix b/pkgs/applications/networking/cluster/terraform-providers/default.nix index 312bf72f5a5a..ebeed89fdf61 100644 --- a/pkgs/applications/networking/cluster/terraform-providers/default.nix +++ b/pkgs/applications/networking/cluster/terraform-providers/default.nix @@ -4,6 +4,7 @@ , fetchFromGitHub , callPackage , config +, writeShellScript , cdrtools # libvirt }: @@ -47,7 +48,12 @@ let ''; # Keep the attributes around for later consumption - passthru = attrs; + passthru = attrs // { + updateScript = writeShellScript "update" '' + provider="$(basename ${provider-source-address})" + ./pkgs/applications/networking/cluster/terraform-providers/update-provider --no-build "$provider" + ''; + }; }); list = lib.importJSON ./providers.json; diff --git a/pkgs/applications/networking/cluster/terraform-providers/update-all-providers b/pkgs/applications/networking/cluster/terraform-providers/update-all-providers index d7a05cf24a65..288c2f345c2c 100755 --- a/pkgs/applications/networking/cluster/terraform-providers/update-all-providers +++ b/pkgs/applications/networking/cluster/terraform-providers/update-all-providers @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#! nix-shell -I nixpkgs=../../../../.. -i bash -p jq +#! nix-shell -i bash -p jq # shellcheck shell=bash # Update all providers which have specified provider source address diff --git a/pkgs/applications/networking/cluster/terraform-providers/update-provider b/pkgs/applications/networking/cluster/terraform-providers/update-provider index 482da6a60275..f0fa979b98cb 100755 --- a/pkgs/applications/networking/cluster/terraform-providers/update-provider +++ b/pkgs/applications/networking/cluster/terraform-providers/update-provider @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#! nix-shell -I nixpkgs=../../../../.. -i bash -p coreutils curl git jq moreutils nix nix-prefetch +#! nix-shell -i bash -p coreutils curl git jq moreutils nix nix-prefetch # shellcheck shell=bash # vim: ft=sh # @@ -100,6 +100,8 @@ echo_provider() { echo "== terraform-providers.${provider}: $* ==" } +pushd "$(dirname "$0")" + if [[ ${provider} =~ ^[^/]+/[^/]+$ ]]; then echo_provider "init" source_address=registry.terraform.io/${provider} @@ -164,3 +166,5 @@ if [[ ${build} == 1 ]]; then echo_provider "building" nix-build --no-out-link "${repo_root}" -A "terraform-providers.${provider}" fi + +popd