Re: Packaging Typst

2024-07-14 Thread Ethan Reece
> Do the typst tests past? Does the binary work?

The typst-cli tests pass and the binary works (I am currently using it for a 
small project). For the typst library, the tests require typst_dev_assets which 
isn't packaged in crates.io or referred to in the typst crate, so I would need 
to point rust-typst to the GitHub version instead of the Crates version or make 
it modify the Crates version to load typst_dev_assets correctly, and also add 
rust-typst-dev-assets to Guix which would point to the typst/typst-dev-assets 
GitHub repo (not sure whether I should do this or just disable tests, and 
should this also go in crates-io.scm or a different file).

> I believe there as a package manager for typst, so if typst packages will be 
> included in guix, would be worth creating a separate file, otherwise the 
> typst cli package could go in markup.scm.

>From what I'm seeing the `typst compile` command, which generates the file, 
>also downloads imported packages from Typst Universe but also accepts local 
>and custom directories, so creating a separate typst.scm file would probably 
>be good.

On Thu, Jul 11, 2024, at 20:34, kiasoc5 wrote:
> On 7/11/24 02:21, Ethan Reece wrote:
> > Hello,
> > 
> > I created a file that packages Typst and its dependencies, and I'm 
> > trying to figure out how to contribute it to the Guix project. What I've 
> > done to generate the file:
> > 
> >   * guix import -i typst-guix.scm crate --recursive
> > --recursive-dev-dependencies --allow-yanked typst-cli
> >   * I had to run this again for pretty_assertions@0.5 for some reason
> >   * Marked the modules licensed as "Unicode-3.0" as license:unicode
> >   * Marked the modules licensed as "Apache-2.0 with LLVM-exception" as
> > license:asl2.0
> >   * Added a snippet at the end (generated with GPT but appears to work)
> > that allows me to build everything in it using "guix build -m
> > typst-guix.scm" and used this to verify that everything builds
> >   * Bumped a few packages from rust-1.75 to rust-1.76 that were
> > complaining about it
> >   * For the packages where tests or build failed, disabled tests or
> > build for that package so that there are no errors when I run the
> > guix build command
> >   * Added pkg-config and openssl as dependencies for rust-typst-cli-0.11
> > 
> > The file has about 2500 lines worth of dependencies, and I'm a bit 
> > confused on how I should handle that. Should I redo all of this on 
> > "crates-io.scm" or a different file? What branch should I do this on? 
> > Should rust-typst-cli be changed to just typst or put in a different 
> > file as that?
> > 
> > - Ethan
> 
> Good job getting this to work!
> 
> Do the typst tests past? Does the binary work?
> 
> I believe that all the crates that came from crates.io should go into 
> crates-io.scm. The typst binary package should simply be called "typst" 
> unless there is a need to distinguish between a cli and gui version. I 
> believe there as a package manager for typst, so if typst packages will 
> be included in guix, would be worth creating a separate file, otherwise 
> the typst cli package could go in markup.scm. I'll let more experienced 
> members confirm or deny these assertions.
> 


Re: Packaging Typst

2024-07-13 Thread jbranso
July 11, 2024 at 9:34 PM, "kiasoc5"  wrote:



> 
> On 7/11/24 02:21, Ethan Reece wrote:
> 
> > 
> > Hello,
> > 
> >  I created a file that packages Typst and its dependencies, and I'm > 
> > trying to figure out how to contribute it to the Guix project. What I've > 
> > done to generate the file:
> > 
> >  * guix import -i typst-guix.scm crate --recursive
> > 
> >  --recursive-dev-dependencies --allow-yanked typst-cli
> > 
> >  * I had to run this again for pretty_assertions@0.5 for some reason
> > 
> >  * Marked the modules licensed as "Unicode-3.0" as license:unicode
> > 
> >  * Marked the modules licensed as "Apache-2.0 with LLVM-exception" as
> > 
> >  license:asl2.0
> > 
> >  * Added a snippet at the end (generated with GPT but appears to work)
> > 
> >  that allows me to build everything in it using "guix build -m
> > 
> >  typst-guix.scm" and used this to verify that everything builds
> > 
> >  * Bumped a few packages from rust-1.75 to rust-1.76 that were
> > 
> >  complaining about it
> > 
> >  * For the packages where tests or build failed, disabled tests or
> > 
> >  build for that package so that there are no errors when I run the
> > 
> >  guix build command
> > 
> >  * Added pkg-config and openssl as dependencies for rust-typst-cli-0.11
> > 
> >  The file has about 2500 lines worth of dependencies, and I'm a bit > 
> > confused on how I should handle that. Should I redo all of this on > 
> > "crates-io.scm" or a different file? What branch should I do this on? > 
> > Should rust-typst-cli be changed to just typst or put in a different > file 
> > as that?
> > 
> >  - Ethan
> > 
> 
> Good job getting this to work!
 
That is a really solid job bro!  Packaging rust stuff, I've heard is really 
hard.  So congrats!  Also I would perhaps wait a few more days to see if any 
other experienced developer gives you some tips on where to store your 
dependencies.  Then I would submit a patch to guix-patc...@gnu.org.  That way 
we can put your contribution in our bug tracker, and we won't lose it.  The 
guix manual has a section for how to contribute a patch:  
https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html


Thanks,

Joshua



Re: Packaging Typst

2024-07-11 Thread kiasoc5

On 7/11/24 02:21, Ethan Reece wrote:

Hello,

I created a file that packages Typst and its dependencies, and I'm 
trying to figure out how to contribute it to the Guix project. What I've 
done to generate the file:


  * guix import -i typst-guix.scm crate --recursive
--recursive-dev-dependencies --allow-yanked typst-cli
  * I had to run this again for pretty_assertions@0.5 for some reason
  * Marked the modules licensed as "Unicode-3.0" as license:unicode
  * Marked the modules licensed as "Apache-2.0 with LLVM-exception" as
license:asl2.0
  * Added a snippet at the end (generated with GPT but appears to work)
that allows me to build everything in it using "guix build -m
typst-guix.scm" and used this to verify that everything builds
  * Bumped a few packages from rust-1.75 to rust-1.76 that were
complaining about it
  * For the packages where tests or build failed, disabled tests or
build for that package so that there are no errors when I run the
guix build command
  * Added pkg-config and openssl as dependencies for rust-typst-cli-0.11

The file has about 2500 lines worth of dependencies, and I'm a bit 
confused on how I should handle that. Should I redo all of this on 
"crates-io.scm" or a different file? What branch should I do this on? 
Should rust-typst-cli be changed to just typst or put in a different 
file as that?


- Ethan


Good job getting this to work!

Do the typst tests past? Does the binary work?

I believe that all the crates that came from crates.io should go into 
crates-io.scm. The typst binary package should simply be called "typst" 
unless there is a need to distinguish between a cli and gui version. I 
believe there as a package manager for typst, so if typst packages will 
be included in guix, would be worth creating a separate file, otherwise 
the typst cli package could go in markup.scm. I'll let more experienced 
members confirm or deny these assertions.




Re: packaging Typst

2023-11-03 Thread Alexis Simon
My current not-yet-working work-in-progress if anyone is interested in 
contributing.


https://codeberg.org/alxsim/local-channel/src/branch/main/typst.scm

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
 

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




Re: packaging Typst

2023-11-03 Thread Steve George
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


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
(define-module (typst)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system cargo)
#:use-module (gnu packages crates-io))

;; guix shell --development guix --container --nesting 
;; guix build --load-path=./ --file=typst.scm


; librsvg in gnome.scm mixes build systems
; greetd in admin.scm does some minor changes

(define-public rust-comemo-0.3
  (package
(name "rust-comemo")
(version "0.3.0")
(source
 (origin
   (method url-fetch)
   (uri (crate-uri "comemo" version))
   (file-name (string-append name "-" version ".tar.gz"))
   (sha256
(base32 "14ng6gqklsy8m9wn6radragn8pazsmn5759mywxb1ddf8bqrg818"
(build-system cargo-build-system)
(arguments
 `(#:cargo-inputs (("rust-comemo-macros" ,rust-comemo-macros-0.3)
   ("rust-siphasher" ,rust-siphasher-0.3
(home-page "https://github.com/typst/comemo;)
(synopsis "Incremental computation through constrained memoization.")
(description "Incremental computation through constrained memoization.")
(license (list license:expat 

Re: packaging Typst?

2023-11-03 Thread Sergio Pastor Pérez
Hi, Alexis.

`typst` seems to use a structure that relies on multiple smaller
crates. There has been some discussions over the IRC on how this could
be packaged using the current cargo build system.

The discussion where I participated revolved around `pathfinder`
(https://github.com/servo/pathfinder).

Unfortunately there has not been any consensus on what could be done to
package this kind of structure.

I'm hoping that someone has some ideas on how to approach the issue.

Thanks.
Sergio.

Alexis Simon  writes:

> Hi,
>
> Is anyone looking into packaging Typst (https://github.com/typst/typst)?
>
> This is a very promising Latex alternative.
>
> If no one is doing that I could try to investigate packaging it but I 
> would need some help on where to start.
> This is a rust app but not available on crates.io.
>
> Thanks!
> Alexis



Re: packaging Typst

2023-11-02 Thread Alexis Simon
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
 

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




Re: packaging Typst? [or other rust apps that have several internal crates]

2023-11-01 Thread Alexis Simon

Thank you Sergio

On 01/11/2023 14:04, Sergio Pastor Pérez wrote:

Hi, Alexis.

`typst` seems to use a structure that relies on multiple smaller
crates. There has been some discussions over the IRC on how this could
be packaged using the current cargo build system.


Yes I asked the question there as I figured this was a more general 
approach to trying to figure out how to package this kind of app.


I'll also add what I mentioned on irc, that packaging helix [1] would be 
pretty similar also.


Maybe someone in the rust team would be willing to look at that and/or 
try to mentor me into looking at rust related packaging.




The discussion where I participated revolved around `pathfinder`
(https://github.com/servo/pathfinder).

Unfortunately there has not been any consensus on what could be done to
package this kind of structure.

I'm hoping that someone has some ideas on how to approach the issue.

Thanks.
Sergio.

Alexis Simon  writes:


Hi,

Is anyone looking into packaging Typst (https://github.com/typst/typst)?

This is a very promising Latex alternative.

If no one is doing that I could try to investigate packaging it but I
would need some help on where to start.
This is a rust app but not available on crates.io.

Thanks!
Alexis


One thing I don't really understand right now in the cargo build system 
is how dependencies are managed compared to other build systems.

If anyone has a beginner blog post or tutorial on that please share.

Cheers,
Alexis

[1] https://github.com/helix-editor/helix



packaging Typst?

2023-10-31 Thread Alexis Simon

Hi,

Is anyone looking into packaging Typst (https://github.com/typst/typst)?

This is a very promising Latex alternative.

If no one is doing that I could try to investigate packaging it but I 
would need some help on where to start.

This is a rust app but not available on crates.io.

Thanks!
Alexis