Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / ty / typst / package.nix
blob11e5b9f5870b1fe72cb429e35e1fed7afe8cd5f8
1 { lib
2 , rustPlatform
3 , fetchFromGitHub
4 , installShellFiles
5 , pkg-config
6 , openssl
7 , xz
8 , stdenv
9 , darwin
10 , nix-update-script
13 rustPlatform.buildRustPackage rec {
14   pname = "typst";
15   version = "0.11.1";
17   src = fetchFromGitHub {
18     owner = "typst";
19     repo = "typst";
20     rev = "v${version}";
21     hash = "sha256-FagjVU8BJZStE/geexZERuV2P28iF/pPn2mTi1Gu9iU=";
22   };
24   cargoLock = {
25     lockFile = ./Cargo.lock;
26     outputHashes = {
27       "typst-dev-assets-0.11.1" = "sha256-SMRtitDHFpdMEoOuPBnC3RBTyZ96hb4KmMSCXpAyKfU=";
28     };
29   };
31   nativeBuildInputs = [
32     installShellFiles
33     pkg-config
34   ];
36   buildInputs = [
37     openssl
38     xz
39   ] ++ lib.optionals stdenv.isDarwin [
40     darwin.apple_sdk.frameworks.CoreFoundation
41     darwin.apple_sdk.frameworks.CoreServices
42     darwin.apple_sdk.frameworks.Security
43   ];
45   env = {
46     GEN_ARTIFACTS = "artifacts";
47     OPENSSL_NO_VENDOR = true;
48   };
50   # Fix for "Found argument '--test-threads' which wasn't expected, or isn't valid in this context"
51   postPatch = ''
52     substituteInPlace tests/src/tests.rs --replace-fail 'ARGS.num_threads' 'ARGS.test_threads'
53     substituteInPlace tests/src/args.rs --replace-fail 'num_threads' 'test_threads'
54   '';
56   postInstall = ''
57     installManPage crates/typst-cli/artifacts/*.1
58     installShellCompletion \
59       crates/typst-cli/artifacts/typst.{bash,fish} \
60       --zsh crates/typst-cli/artifacts/_typst
61   '';
63   cargoTestFlags = [ "--workspace" ];
65   passthru.updateScript = nix-update-script { };
67   meta = {
68     changelog = "https://github.com/typst/typst/releases/tag/${src.rev}";
69     description = "New markup-based typesetting system that is powerful and easy to learn";
70     homepage = "https://github.com/typst/typst";
71     license = lib.licenses.asl20;
72     mainProgram = "typst";
73     maintainers = with lib.maintainers; [ drupol figsoda kanashimia ];
74   };