> > > I have modified cargo2guix to support git checkouts but commented it out 
> > > due to
> > > lack of cargo-build-system support.
> >
> > Looking at guix/build/cargo-build-system, the "easiest" option would be
> > to take the git-checkout and then turn it into a .tar.gz.  Otherwise
> > crate-src? and 'configure would need to be adjusted to handle git
> > checkouts.
>
> Will do, I actually looked at this but stopped after knowing 
> cargo-build-system
> doesn't support Cargo workspaces.
>
> Just found out that Cargo workspaces can be packaged with:
> --8<---------------cut here---------------start------------->8---
> RUSTC_BOOTSTRAP=1 cargo package --workspace --registry crates-io -Z 
> package-workspace
> --8<---------------cut here---------------end--------------->8---
>
> I'll look into Cargo workspaces support too.

It works, I'll try to reorganize cargo-build-system in a new branch, since this
will be incompatible with current Guix and requires more effort.

> > > * Deletion of unused variables
> > >
> > > I have deletion logic in mind but don't know how to implement it at the 
> > > moment:
> > > --8<---------------cut here---------------start------------->8---
> > > While reading file MODULE, find definitions
> > > If the definition is ‘(delay (list ...))’, add content of the list to 
> > > REFERENCES.
> > > Otherwise add the definition name to VARIABLES
> > >
> > > UNUSED_VARIABLES = VARIABLES - REFERENCES
> > >
> > > Delete UNUSED_VARIABLES from MODULES in one go.
> > > --8<---------------cut here---------------end--------------->8---
> >
> > Would it be easier to have 1 package per module, as in just the cargo
> > inputs for zoxide in gnu/packages/rust-crates/zoxide.scm, and then you
> > wouldn't need to worry about removing variables that aren't used by
> > zoxide anymore but are used by another package?
>
> Here's a working implementation using bash, grep, cut and sed.  The logic is 
> a bit
> different since it's not fully in Guile. :)
> --8<---------------cut here---------------start------------->8---
> FILE=gnu/packages/rust-crates.scm
> PATTERN='^(define-public rust-'
>
> for crate in $(grep "$PATTERN" $FILE | cut -d' ' -f2)
> do
>     if [ "$(grep -wc "$crate" $FILE)" -eq 1 ]; then
>         echo "(begin
>                 (use-modules ((srfi srfi-11))
>                               (guix utils))
>                 (let-values
>                     (((source-properties term-exists)
>                       (find-definition-insertion-location \"$FILE\" '$crate)))
>                   (when term-exists
>                     (delete-expression source-properties))))" |
>             guix repl -t machine
>     fi
>     # Delete extra newlines.
>     sed --in-place ':a;N;$!ba;s/\n\n\+/\n\n/g' $FILE
> done
> --8<---------------cut here---------------end--------------->8---

Added here:
https://git.boiledscript.com/hako/guix/commit/b990a0d87339a0e5f591abd98475e2342e0e87b7
, with a new module boilerplate.

When using the script, please change the ‘guix’ to a ‘guix time-machine’ call or
whatever you do to use my fork.

> > > * Package cargo-audit[1] and cargo-license[2] or similiar software, and 
> > > write a
> > >   step-by-step packaging workflow.
> > >
> > > [1] https://github.com/rustsec/rustsec/tree/main/cargo-audit
> > > [2] https://github.com/onur/cargo-license
> >
> > What's the reasoning behind delay and force for the
> > <package>-cargo-inputs?
> >
> > I think the source-only cargo inputs shouldn't be public variables, only
> > the <package>-cargo-inputs variable.
>
> These issues are related to ‘--insert’:
> 1. ‘find-definition-insertion-location’ searches ‘define-public’.
> 2. *-cargo-inputs may be insert before its dependencies.
>
> I'll see how I can solve them.

Done

Reply via email to