typst: add initial support for typst packages#369283
Conversation
b5ab425 to
0bcf7c9
Compare
There was a problem hiding this comment.
Welcome to Nixpkgs! This is truly amazing; I've wanted to build Typst packages for a very long time but never got around to it.
Note that the commits should be split as much as possible. Each new typstPackage should be added in a separate commit. The changes to the base typst package to wrap it should also be a separate commit.
407f204 to
b14cd40
Compare
SigmaSquadron
left a comment
There was a problem hiding this comment.
Regarding the actual package set, even though we can't import from Universe directly, it might still be a good idea to scrape it for information and build packages automatically. typst.toml gives us all of the necessary information to build each package.
Ah that is great. Didn't know they already have that information included. I'll work on the script when I got time, but it will have to be waited for another week or so. |
SigmaSquadron
left a comment
There was a problem hiding this comment.
Looks good to me, just one final open question for anyone who knows about packagesFromDirectoryRecursive.
e753a45 to
7560346
Compare
|
Would it be a good idea to have some documentation for this ? |
I can write it, but where should I put it?
Not sure if this change should be considered as significant |
|
Looks like the archive content still is not immutable, though: typst/packages#2043 (comment) |
They are not. Packages are allowed to have minor fixes. But for now I suspect we no longer suffer from hash instability using |
philiptaron
left a comment
There was a problem hiding this comment.
Given the number of packages added, should this target staging? cc @mweinelt and @vcunat.
I see eight builds failing from typstPackages:
typstPackages.glossarium_0_2_3typstPackages.glossarium_0_2_4typstPackages.numty_0_0_5typstPackages.glossarium_0_2_0typstPackages.glossarium_0_2_5typstPackages.glossarium_0_1_0typstPackages.ncku-later_0_1_0typstPackages.songb_0_1_0
I was surprised to see so many previous releases in this package set.
There was a problem hiding this comment.
Does this too want to be lib.extendMkDerivation, this time with buildEnv as the build helper?
|
The builder seems to be mostly copying stuff around, so it is probably fine to take into master. Please make sure to fix or disable the broken packages before going for the merge. |
Here is the thing. Since the broken packages is due to the upstream changing their content (and thus their hash), if we can mark the package is broken, we can update its hash to unbroken it. So we can do nothing more about it --- we can always make sure the package is latest before merge but they are going to be broken, soon or later, when the upstream updates the package content |
|
After doing a build on |
philiptaron
left a comment
There was a problem hiding this comment.
I think gaining access to the typst universe is worth more than whatever nits I might make. All packages save for a few old ones build successfully.
nim65s
left a comment
There was a problem hiding this comment.
fwiw I've been using this a bit and I'm super happy with it. Thanks ! :)
|
Is there a CI to keep packages up-to-date for nixpkgs? Also, lmk if there's anything else I need to fix if not merging it |
|
Yes, if an individual package has a There is nothing like this for whole package sets at once. |
|
Oh I did not think to look here, I made my own little library for building Typst packages a little bit ago integrating into nixpkgs is much nicer though. The main difference is that my library allows to put packages into custom namespaces. |
This is very nice! It would complete the support to build Typst documents (and can perhaps reuse infrastructures provided by this PR) in Nix :) This PR aims to provide a way to instantiate a Typst environment that contains packages from Typst Universe --- meaning that to build a Typst document, you would still need to write the primitive |
|
I merged this PR since it has 3 approvals. Congratulations on all the work done in here! |
|
Nice to finally see this live 🎉 |
|
"Build Nixpkgs Manual v2" action is failing since this PR was merged. |
|
@cherrypiejam The file |
There's an script It wouldn't be 3 month old tho cuz I think I updated it one a month ago. I am happy to integrate it if there's a CI for automatic nixpkgs updating |
Yeah we should automate the updates. Perhaps @emaryn could help ? |
What's the constraint here tho? This script could be run less frequently (bidaily or weekly?) since it fetches all packages from the Typst universe |
Oh nice. Is this attribute defined under the |
This PR adds initial support to build Typst documents with Typst packages. In particular, it adds a Typst package builder and exposes it at the top level to ease the process of defining new Typst packages. It further adds a new function to the Typst derivation for creating a new Typst environment in which the Typst compiler understands a specific set of packages, namely
typst.withPackages. Moreover, three Typst packages are defined and collected as a single attribution set as an initial demonstration.Only a few Typst packages are included in this PR for a reason. The Typst Universe (the official site for Typst packages) maintains a single git repo that contains all Typst packages. Each package entry does not necessarily map to the same version specified in their respective git repo published by their authors (if there is). This is because the package authors need to manually move their package and copy the source, instead of a pointer, to the Typst Universe repo. Breaking the Typst Universe repo down to per package requires separate places to store each of them, and due to the aforementioned reason, the exact source may disagree with the original git repo 1. This is why, in my opinion, we might want to collect our own set of Typst packages instead of directly pulling from the Typst Universe repo. For gradual adaption,typst.withPackagesalso provides a method to override the predefined set of Typst packages, namelytypst.withPackages.override, making it easier for end users overriding the existing set of Typst packages and integrating new packages into their project.All packages from the Typst Universe are included in this PR, along with a maintenance script. The script simply generates a set of nix expressions for all packages from the Typst Universe. Each individual package is now fetched as a tarball from the Typst Universe instead of their individual repository.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.
Footnotes
Assuming the author(s) also publish their package in another repo outside of the Typst Universe repo. ↩