[bug#76513,rust-team,00/77] Add module (gnu packages typst) and packages

Message ID cover.1740340804.git.wongandj@icloud.com
Headers
Series Add module (gnu packages typst) and packages |

Message

Andrew Wong Feb. 23, 2025, 8:03 p.m. UTC
  This patch series adds the typesetting system Typst and the module (gnu packages typst) to the rust-team branch.

Andrew Wong (77):
  gnu: rust-diesel-2: Update to 2.2.7.
  gnu: rust-diesel-derives-2: Update to 2.2.3.
  gnu: Add rust-diesel-table-macro-syntax-0.2.
  gnu: Add rust-dsl-auto-type-0.1.
  gnu: Add rust-mysqlclient-src-0.1.
  gnu: Add rust-pq-src-0.3.
  gnu: Add rust-image-webp-0.1.
  gnu: Add rust-imagesize-0.13.
  gnu: Add rust-kamadak-exif-0.6.
  gnu: Add rust-kurbo-0.11.
  gnu: Add rust-pixglyph-0.5.
  gnu: Add rust-qcms-0.3.
  gnu: Add rust-resvg-0.43.
  gnu: Add rust-rustybuzz-0.18.
  gnu: Add rust-svg2pdf-0.12.
  gnu: Add rust-svgtypes-0.15.
  gnu: Add rust-ttf-parser-0.24.
  gnu: Add rust-biblatex-0.10.
  gnu: rust-bitflags-2: Update to 2.8.0.
  gnu: Add rust-chinese-number-0.7.
  gnu: Add rust-chinese-variant-1.
  gnu: Add rust-citationberg-0.5.
  gnu: Add rust-codex-0.1.
  gnu: Add rust-comemo-0.4.
  gnu: Add rust-comemo-macros-0.4.
  gnu: Add rust-ecow-0.2.
  gnu: Add rust-dirs-6.
  gnu: Add rust-fontconfig-parser-0.5.
  gnu: Add rust-fontdb-0.21.
  gnu: Add rust-hayagriva-0.8.
  gnu: Add rust-hypher-0.1.
  gnu: Add rust-icu-provider-adapters-1.
  gnu: Add rust-icu-provider-blob-1.
  gnu: Add rust-icu-segmenter-1.
  gnu: Add rust-icu-segmenter-data-1.
  gnu: Add rust-indexmap-nostd-0.4.
  gnu: Add rust-lipsum-0.9.
  gnu: Add rust-multi-stash-0.2.
  gnu: Add rust-mutate-once-0.1.
  gnu: Add rust-notify-8.
  gnu: Add rust-notify-types-2.
  gnu: Add rust-numerals-0.1.
  gnu: Add rust-openssl-src-300.
  gnu: Add rust-pdf-writer-0.12.
  gnu: rust-rust-decimal-1: Update to 1.36.0.
  gnu: Add rust-self-replace-1.
  gnu: Add rust-sigpipe-0.1.
  gnu: Add rust-simplecss-0.2.
  gnu: Add rust-siphasher-1.
  gnu: rust-strict-num-0.1: Update to 0.1.1.
  gnu: Add rust-string-interner-0.17.
  gnu: Add rust-string-interner-0.18.
  gnu: Add rust-subsetter-0.2.
  gnu: rust-two-face-0.4: Update to 0.4.3.
  gnu: Add rust-unic-langid-0.9.
  gnu: Add rust-unic-langid-impl-0.9.
  gnu: Add rust-unic-langid-macros-0.9.
  gnu: Add rust-unic-langid-macros-impl-0.9.
  gnu: Add rust-unicode-bidi-mirroring-0.3.
  gnu: Add rust-unicode-ccc-0.3.
  gnu: Add rust-unicode-math-class-0.1.
  gnu: Add rust-unicode-properties-0.1.
  gnu: Add rust-unicode-script-0.5.
  gnu: Add rust-unicode-vo-0.1.
  gnu: Add rust-usvg-0.43.
  gnu: Add rust-wasmi-0.40.
  gnu: Add rust-wasmi-0.36.
  gnu: Add rust-wasmi-collections-0.40.
  gnu: Add rust-wasmi-collections-0.36.
  gnu: Add rust-wasmi-core-0.36.
  gnu: Add rust-wasmi-core-0.40.
  gnu: Add rust-wasmi-ir-0.40.
  gnu: Add rust-wasmparser-0.221.
  gnu: Add rust-wasmparser-nostd-0.100.
  gnu: Add rust-xmp-writer-0.3.
  gnu: Add rust-zerotrie-0.1.
  gnu: Add new module (gnu packages typst).

 gnu/local.mk                     |    1 +
 gnu/packages/crates-database.scm |   99 ++-
 gnu/packages/crates-graphics.scm |  264 ++++++
 gnu/packages/crates-io.scm       | 1349 +++++++++++++++++++++++++++++-
 gnu/packages/typst.scm           |  607 ++++++++++++++
 5 files changed, 2296 insertions(+), 24 deletions(-)
 create mode 100644 gnu/packages/typst.scm


base-commit: e0b32172cdbf6f8a77a020f883ece7faa668dc2d
  

Comments

Ludovic Courtès Feb. 26, 2025, 10:43 p.m. UTC | #1
Hi Andrew,

Andrew Wong <wongandj@icloud.com> skribis:

> This patch series adds the typesetting system Typst and the module (gnu packages typst) to the rust-team branch.

FWIW, Typst is available in Guix-Science, thanks to Alexis Simon (Cc’d).

(I think we have a maintainability problem with Rust packages as it
stands.  With cargo2nix among other things, some are experimenting with
simpler and more sustainable ways to provide Rust packages; I hope
that’ll come to fruition.)

Ludo’.
  
Andrew Wong Feb. 27, 2025, 12:28 a.m. UTC | #2
On 2/26/25 5:43p, Ludovic Courtès wrote:> FWIW, Typst is available in 
Guix-Science, thanks to Alexis Simon (Cc’d).
Indeed, I found it there after I made this patch series. I'm working on 
a v2 which integrates Alexis' work and adds them as a credit.

> I think we have a maintainability problem with Rust packages as it
> stands.Yeah, I think patch series like these really show the limits of our 
current system.
  
Alexis Simon Feb. 27, 2025, 10:31 a.m. UTC | #3
See also this PR by @Ingar and the current bug in 0.13 I mention in the 
last comment
https://codeberg.org/guix-science/guix-science/pulls/81
Alexis

On 27/02/2025 01:28, Andrew Wong wrote:
> On 2/26/25 5:43p, Ludovic Courtès wrote:> FWIW, Typst is available in 
> Guix-Science, thanks to Alexis Simon (Cc’d).
> Indeed, I found it there after I made this patch series. I'm working on 
> a v2 which integrates Alexis' work and adds them as a credit.
> 
>> I think we have a maintainability problem with Rust packages as it
>> stands.Yeah, I think patch series like these really show the limits of 
>> our 
> current system.
  
Andrew Wong March 2, 2025, 5:39 a.m. UTC | #4
Hi All,

I've been working on implementing Alexis' changes and suggestions. 
However, I've run into a roadblock regarding the bug you mentioned in 
version 0.13.0. Though the bug has been fixed a few days ago, trying to 
build typst from the fixing commit has led me to a few roadblocks, 
because the git-packaged version of Typst depends on downloading 
git-packaged versions of its component packages, which I then tried to 
package themselves but ran up against more roadblocks. Has anyone here 
successfully packaged rust packages with github dependencies? Any 
notes/pointers/examples? I tried grepping around guix but couldn't find 
a good example.

So far, I've just been trying to build the release version as retrieved 
from git, because it only has one git dependency 
'rust-typst-dev-assets', but I can't get even that to build, so I am 
stumped. Is it OK if I just send in the next version of the patch series 
(with the search path fixes) and either a) allow someone with the skills 
to implement the fix after the patches are merged or b) wait (or ask) 
for the typst developers to release a "0.13.1" with the fix?
  
Murilo March 2, 2025, 1:34 p.m. UTC | #5
Hi Andrew,

On Sun Mar 2, 2025 at 2:39 AM -03, Andrew Wong via Guix-patches via wrote:
> Hi All,
>
> I've been working on implementing Alexis' changes and suggestions. 
> However, I've run into a roadblock regarding the bug you mentioned in 
> version 0.13.0. Though the bug has been fixed a few days ago, trying to 
> build typst from the fixing commit has led me to a few roadblocks, 
> because the git-packaged version of Typst depends on downloading 
> git-packaged versions of its component packages, which I then tried to 
> package themselves but ran up against more roadblocks. Has anyone here 
> successfully packaged rust packages with github dependencies? Any 
> notes/pointers/examples? I tried grepping around guix but couldn't find 
> a good example.

You can try:
------
(snippet
  #~(begin (use-modules (guix build utils))
           (substitute* "Cargo.toml"
             (("typst-dev-assets = \\{ git =.+")
              "typst-dev-assets = \"0.13.0\"\n"))))
------

Along with:
------
(arguments '(#:install-source? #f))
------

It should solve the immediate problem, but might create others, depends on how
the rust program does the workspacing, e.g. you might get errors like this:

------
error: manifest path `/path/to/source/Cargo.toml` is a virtual manifest, but
this command requires running against an actual package in this workspace
------

> So far, I've just been trying to build the release version as retrieved 
> from git, because it only has one git dependency 
> 'rust-typst-dev-assets', but I can't get even that to build, so I am 
> stumped.

Building the package directly from git (with git as a source) is different than
using crate-uri as a source. Reason being crates.io (or cargo in the broader
instance) does something called 'normalization' to its workspace packages, and,
as a consequence, dependencies, before shipping them as a '.crate' file. The
crates.io registry might not even ship 'typst-dev-assets' in this case, since
its a dev dependency (this is why it builds fine when using crate-uri instead
of git-reference).

What this means in practice, without diving into cargo-build-system too deep, is
it converts a 'virtual manifest' to actual packages that can be worked on using
subsequent cargo subcommands (like 'cargo package').

AFAIK (and I'd be really happy to be proved wrong here!), theres no easy way
to do this normalization without internet access, or without lock files (which
currently gets deleted by the cargo-build-system).

I wish I could give you any reference links to read or prove my statements,
however this is all from my own experience packaging rust, and many failed
attempts on even harder packages.

Back to your original problem, I think these steps would do the trick:

1. Remove the hard-dependency on git with the above substitute* snippet;
2. #:install-source? #f as the package argument;
3. Replace the 'install phase with your own that installs the files.

Not that you have to do it (see the "option 'c'" below), but just giving you one
(of many) ways to solve this specific problem if you/anyone reading this finds
it useful (specially for packaging crates that are not in crates.io).

> Is it OK if I just send in the next version of the patch series 
> (with the search path fixes) and either a) allow someone with the skills 
> to implement the fix after the patches are merged or b) wait (or ask) 
> for the typst developers to release a "0.13.1" with the fix?

I don't know the proper guix procedure for this case, sorry.
However I can suggest applying the specific commit [1] from the fix PR [2] as a
guix patch - could be an option "c" :)

Best regards,
Murilo

[1] https://github.com/typst/typst/commit/acd3a5b7a5999d22fbf2da488744d564b2f3638e
[2] https://github.com/typst/typst/pull/5905