Unverified Commit 662fc85d authored by Lin Jian's avatar Lin Jian Committed by GitHub
Browse files

Merge pull request #330993 from adisbladis/melpa-libgenerated-fetchers

emacs.pkgs.melpaPackages: Refactor internal melpaDerivation fetcher invocation
parents a2e89685 d70672d9
Loading
Loading
Loading
Loading
+105 −57
Original line number Diff line number Diff line
lib: self:

let
  inherit (lib) elemAt;

    fetcherGenerators = { repo ? null
                        , url ? null
                        , ... }:
                        { sha256
                        , commit
                        , ...}: {
      github = self.callPackage ({ fetchFromGitHub }:
  matchForgeRepo = builtins.match "(.+)/(.+)";

  fetchers = lib.mapAttrs (_: fetcher: self.callPackage fetcher { }) {
    github =
      { fetchFromGitHub }:
      {
        repo ? null,
        ...
      }:
      { sha256, commit, ... }:
      let
        m = matchForgeRepo repo;
      in
      assert m != null;
      fetchFromGitHub {
          owner = lib.head (lib.splitString "/" repo);
          repo = lib.head (lib.tail (lib.splitString "/" repo));
        owner = elemAt m 0;
        repo = elemAt m 1;
        rev = commit;
        inherit sha256;
        }
      ) {};
      gitlab = self.callPackage ({ fetchFromGitLab }:
      };

    gitlab =
      { fetchFromGitLab }:
      {
        repo ? null,
        ...
      }:
      { sha256, commit, ... }:
      let
        m = matchForgeRepo repo;
      in
      assert m != null;
      fetchFromGitLab {
          owner = lib.head (lib.splitString "/" repo);
          repo = lib.head (lib.tail (lib.splitString "/" repo));
        owner = elemAt m 0;
        repo = elemAt m 1;
        rev = commit;
        inherit sha256;
        }
      ) {};
      git = self.callPackage ({ fetchgit }:
      };

    git = (
      { fetchgit }:
      {
        url ? null,
        ...
      }:
      { sha256, commit, ... }:
      (fetchgit {
        rev = commit;
        inherit sha256 url;
      }).overrideAttrs(_: {
        GIT_SSL_NO_VERIFY = true;
      })
      ) {};
      bitbucket = self.callPackage ({ fetchhg }:
    );

    bitbucket =
      { fetchhg }:
      {
        repo ? null,
        ...
      }:
      { sha256, commit, ... }:
      fetchhg {
        rev = commit;
        url = "https://bitbucket.com/${repo}";
        inherit sha256;
        }
      ) {};
      hg = self.callPackage ({ fetchhg }:
      };

    hg =
      { fetchhg }:
      {
        url ? null,
        ...
      }:
      { sha256, commit, ... }:
      fetchhg {
        rev = commit;
        inherit sha256 url;
        }
      ) {};
      sourcehut = self.callPackage ({ fetchzip }:
      };

    sourcehut =
      { fetchzip }:
      {
        repo ? null,
        ...
      }:
      { sha256, commit, ... }:
      fetchzip {
        url = "https://git.sr.ht/~${repo}/archive/${commit}.tar.gz";
        inherit sha256;
        }
      ) {};
      codeberg = self.callPackage ({ fetchzip }:
      };

    codeberg =
      { fetchzip }:
      {
        repo ? null,
        ...
      }:
      { sha256, commit, ... }:
      fetchzip {
        url = "https://codeberg.org/${repo}/archive/${commit}.tar.gz";
        inherit sha256;
        }
      ) {};
      };
  };

in {
@@ -88,7 +136,7 @@ in {
                (builtins.filter (n: n >= 0) version)));
            # TODO: Broken should not result in src being null (hack to avoid eval errors)
            src = if (sha256 == null || broken) then null else
              lib.getAttr fetcher (fetcherGenerators args sourceArgs);
              fetchers.${fetcher} args sourceArgs;
            recipe = if commit == null then null else
              fetchurl {
                name = pname + "-recipe";