From: Alexis Simon <alexis.simon@runbox.com>
To: de4f8986-1da8-4fcc-a921-b0155ebc7277@runbox.com
Cc: guix-devel@gnu.org
Subject: Re: packaging Typst
Date: Thu, 2 Nov 2023 13:32:26 -0700 [thread overview]
Message-ID: <d8a5fc22-712a-4147-bf8f-42f2f73193e7@runbox.com> (raw)
In-Reply-To: <20231102202124.GA835027@t25sg>
Thank you very much Steve for those detailed explanations! This is going
to be super helpful as a starter.
Alexis
On 02/11/2023 13:21, Steve George wrote:
> Hi Alexis,
>
> I've been doing some Rust packaging recently, so maybe this will help you to get started. Here's how I would approach it.
>
> Explore the software
> ====================
> The first thing I did was explore whether Typst builds in a current Guix environment. If we don't have the right version of Rust, for example, there's little point continuing:
>
> - clone it into an appropriate place
> - start a shell:
> $ guix shell --container --network rust rust-cargo coreutils openssl nss-certs gcc-toolchain
>
> We need 'openssl' and 'nss-certs' so that cargo will work.
>
> - build it:
> [env]$ env CC=gcc cargo build
>
> Kept failing on ring v0.17.5 which is looking for 'cc'. It builds with 296 crates, so we might have our hands full here! Eventually outputs a /target/debug/typst command which seems to work.
>
>
> Import using Guix import
> =========================
> Normally, we'd be able to use the `crates` importer. But, the Typst crates are just place-holders with no details.
>
> AFAIK the importer only works with crates-io, we can't feed it Cargo.toml file directly. We'll need to manually create a package and check for any dependencies.
>
> Manually create a top-level package
> ====================================
> To manually create the package we have to go through the projects Cargo.toml.
>
> - create an intial typst.scm file in some project directory.
> - create a minimal typst package by looking in Cargo.lock at 'typst'
> - for each dependency look at what the Cargo.lock used to build it - check whether we have it in Guix
> - in some cases we will have the crate, but not the right version
>
> Import the dependencies
> =============================
> The first crate that I found which we don't have in the Guix archive is 'comemo' [0]. We can import this with:
>
> $ guix shell --development guix --container --nesting --network nss-certs
> [env]$ guix import crate --recursive comemo@0.3.0 > comemo-import.scm
>
> Move these package definitions into your main `typst.scm` file. Check them to add any missing development dependencies.
>
> The first one in the dependency stack is `rust-comemo-0.3` which we reference at the bottom of the file. We try and build it as the importer has pulled it in:
>
> $ guix shell --development guix --container --nesting
> [env]$ guix build --load-path=./ --file=typst.scm
> <successfully builds>
>
> The next one `rust-comemo-macros` which has been set to `skip-build: #t`, we'll try building it that way initially:
>
> - add rust-comemo-macros-0.3 to the bottom of the typst.scm file
> - comment out the rust-comemo-0.3 line
> - try and build with: guix build --load-path=./ --file=typst.scm
>
> - If it builds successfully, change the `skip-build: #t` part of the definition to be #f.
> - error[E0433]: failed to resolve: use of undeclared crate or module `comemo`
> - tried adding comemo as a dependency which didn't work
> - set it to #:tests? #f - for now
>
> There's some more things that have to be done to 'contribute' these packages, but for now I would move onto the next dependency. And that's all there is to this part - finding the dependencies and importing them.
>
> Building a dependent package that's not a crate
> ===============================================
> The cargo-build-system expects to build everything from Crates AFAIK. I believe it will take some messing around with the phases to add the typst-lib which seems to be a dependency. It looks like librsvg (in gnome.scm) does a lot of messing with phases, and greetd (in admin.scm) does some as well - these might be good examples to look at.
>
> Hopefully this is enough to get you started!
>
> Steve
>
> [0] https://crates.io/crates/comemo
next prev parent reply other threads:[~2023-11-02 20:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 20:21 packaging Typst Steve George
2023-11-02 20:32 ` Alexis Simon [this message]
2023-11-03 21:41 ` Alexis Simon
-- strict thread matches above, loose matches on Subject: below --
2024-07-11 6:21 Packaging Typst Ethan Reece
2024-07-12 1:34 ` kiasoc5
2024-07-13 13:40 ` jbranso
2024-07-14 19:52 ` Ethan Reece
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d8a5fc22-712a-4147-bf8f-42f2f73193e7@runbox.com \
--to=alexis.simon@runbox.com \
--cc=de4f8986-1da8-4fcc-a921-b0155ebc7277@runbox.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).