From eb03b576749c0560458a6f3e4e76715699406e04 Mon Sep 17 00:00:00 2001 From: Fernando Rodrigues Date: Tue, 26 Aug 2025 00:46:45 +1000 Subject: [PATCH] fetchTraefikPlugin: init This function takes in the provider, owner and plugin name, and outputs a correctly-formatted derivation with the Traefik plugin, which can be `symlinkJoin`ed in the `/var/lib/traefik/plugins-local` folder. Signed-off-by: Fernando Rodrigues --- .../fetchtraefikplugin/default.nix | 59 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 61 insertions(+) create mode 100644 pkgs/build-support/fetchtraefikplugin/default.nix diff --git a/pkgs/build-support/fetchtraefikplugin/default.nix b/pkgs/build-support/fetchtraefikplugin/default.nix new file mode 100644 index 0000000000000..4dd05a01038c0 --- /dev/null +++ b/pkgs/build-support/fetchtraefikplugin/default.nix @@ -0,0 +1,59 @@ +{ + lib, + fetchzip, + traefik, +}: + +lib.extendMkDerivation { + constructDrv = fetchzip; + extendDrvArgs = + finalAttrs: + { + plugin, + owner, + provider ? "github.com", # Most Traefik plugins are developed in GitHub repositories. + + version, + hash, + + pname ? plugin, + name ? "${pname}-${version}", + meta ? { }, + }: + let + moduleName = lib.concatStringsSep "/" [ + provider + owner + plugin + ]; + in + { + inherit + hash + name + ; + + url = "https://plugins.traefik.io/public/download/${moduleName}/${version}"; + postFetch = '' + export tmpdir=$(mktemp -d) + mv -R * .* $tmpdir + mkdir -p $out/src/${moduleName} + mv -R $tmpdir/* $tmpdir/.* $out/src/${moduleName} + ''; + + passthru = { + inherit + moduleName + plugin + provider + owner + ; + }; + + meta = { + homepage = "https://plugins.traefik.io/plugins"; + inherit (traefik) platforms; + } + // meta; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 04521e6c4eab7..bbafa326a4450 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -707,6 +707,8 @@ with pkgs; fetchPypiLegacy = callPackage ../build-support/fetchpypilegacy { }; + fetchTraefikPlugin = callPackage ../build-support/fetchtraefikplugin { }; + resolveMirrorURLs = { url }: fetchurl {