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 {