Commit d70672d9 authored by adisbladis's avatar adisbladis
Browse files

emacs.pkgs.melpaPackages: Use regex match to extract owner/repo from repo parameter

This should be a little bit more efficient, but also more readable.
parent 6d1296e8
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
lib: self:

let
  inherit (lib) elemAt;

  matchForgeRepo = builtins.match "(.+)/(.+)";

  fetchers = lib.mapAttrs (_: fetcher: self.callPackage fetcher { }) {
    github =
@@ -10,9 +13,13 @@ let
        ...
      }:
      { 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;
      };
@@ -24,9 +31,13 @@ let
        ...
      }:
      { 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;
      };