summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ty/typst/build-universe-package.nix
blob: af1e0cf4dbe3ec6c3d03ef24d25472d19e73ef37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
  lib,
  buildTypstPackage,
  fetchzip,
  typstPackages,
}:
lib.extendMkDerivation {
  inheritFunctionArgs = false;
  constructDrv = buildTypstPackage;

  excludeDrvArgNames = [
    "description"
    "hash"
    "license"
    "homepage"
    "typstDeps"
  ];

  extendDrvArgs =
    finalAttrs:
    {
      pname,
      version,
      description,
      hash,
      license,
      homepage ? null,
      typstDeps ? [ ],
    }:
    {
      src = fetchzip {
        inherit hash;
        url = "https://packages.typst.org/preview/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
        stripRoot = false;
      };

      typstDeps = builtins.filter (x: x != null) (
        lib.map (d: (lib.attrsets.attrByPath [ d ] null typstPackages)) typstDeps
      );

      meta = {
        inherit description;
        maintainers = with lib.maintainers; [
          cherrypiejam
          RossSmyth
        ];
        license = lib.map (lib.flip lib.getAttr lib.licensesSpdx) license;
        # Sending a bunch of trivial jobs to Hydra is not that great.
        hydraPlatforms = [ ];
      }
      // lib.optionalAttrs (homepage != null) { inherit homepage; };
    };
}