Hi~

I'm new to guix.

Could anyone with more Guix packaging experience point me in the right
direction? I'm particularly confused about why cargo isn't being found and
whether I'm correctly using the cargo-build-system phases within a
CMake-based package.

*I'm trying to create a Guix package definition (.scm file) for Kime*, a
Korean input method framework written in Rust (GitHub:
https://github.com/Riey/kime). *My goal is to replicate the build process
of their provided scripts/build.sh -ar script within a Guix package.*

However, I'm running into a couple of issues when I try to build the
package using guix package -f kime.scm.

*Problem 1: "In execvp of cargo: No such file or directory"*

I'm getting this error during the cargo-build phase. It seems like cargo
isn't being found in the build environment, even though I've included rust
and rust-toolchain in native-inputs.

*Problem 2: Potential issue with cargo configure phase (if uncommented)*

In my kime.scm, I initially tried to explicitly include a configure phase
for Cargo (based on my understanding of how build systems work), but when I
uncommented the (assoc-ref cargo:%standard-phases 'configure) part in my
phases definition, I encountered another error (unfortunately, I didn't
save the exact error message for this one, but I can reproduce it if
needed). [If you can reproduce the error, it's highly recommended to
include it here!]

============
Context & Relevant Logs:

-------
Here is current kime.scm

(use-modules (guix)
         (guix packages)
         (guix git-download)
         (guix build-system cmake)
         (guix build-system cargo)
         (guix build utils)
         (guix gexp)
         (gnu packages rust)
         (gnu packages gcc)
         (gnu packages llvm)
         (gnu packages crates-io)
         (gnu packages crates-gtk)
         (gnu packages freedesktop)
         (gnu packages pkg-config)
         (gnu packages fontutils)
         (gnu packages glib)
         (gnu packages gtk)
         (gnu packages qt)
         (gnu packages xorg)
         ((guix licenses) #:prefix license:)
         )


(define kime
  (package
    (name "kime")
    (version "v3.1.1")
    (source
     (origin
       (method git-fetch)
       (uri
        (git-reference
         (url "https://github.com/Riey/kime.git";)
         (commit "632875f541d8373c90403e74f991d3f5beaeba94")))
       (file-name
        (git-file-name name version))
       (sha256
        (base32 "17nk74k3ydlc45djd4p30ws2ybnilskkxvnvha1n4lq9lh9g8idi"))))
    (build-system cmake-build-system)

    (arguments
      (list
        #:build-type "Release"
        #:imported-modules (append %cargo-build-system-modules  ;
Import cargo modules
                             %cmake-build-system-modules) ; Import cmake modules
        #:modules
        `(((guix build cargo-build-system) #:prefix cargo:)  ;
Instantiate cargo build system with prefix 'cargo:'
          ,@%cmake-build-system-modules)                  ; Include
cmake modules

        #:configure-flags
        #~'( "-DCMAKE_BUILD_TYPE=Release" ; Explicitly state Release
build type, though default in build-options
             "-DUSE_SYSTEM_ENGINE=OFF"   ; Explicitly set to default OFF
             "-DENABLE_GTK3=ON"
             "-DENABLE_GTK4=ON"
             "-DENABLE_QT5=ON"
             "-DENABLE_QT6=ON")

        ; `(#:cargo-inputs  ; Pass cargo-inputs here to configure phase
        ;    (("rust-glib", rust-glib-0.18)
        ;      ("rust-libc", rust-libc-0.2)))

        #:phases
        #~(modify-phases %standard-phases
          (add-before 'configure 'cargo-build
            (lambda* (#:key inputs #:allow-other-keys)
              ; ((assoc-ref cargo:%standard-phases 'unpack-rust-crates)
              ;  #:inputs inputs
              ;  #:vendor-dir "guix-vendor")
              ; ((assoc-ref cargo:%standard-phases 'configure)
              ;   #:inputs inputs)
              ; ((assoc-ref cargo:%standard-phases 'patch-cargo-checksums))
              ((assoc-ref cargo:%standard-phases 'build))
              )))))

    (inputs (list dbus
                  fontconfig
                  glib
                  gtk
                  qtbase
                  qttools
                  clang-runtime
                  cairo
                  xorg-server
                  xcb-util
                  xcb-proto
                  wayland
                  wayland-protocols
                  rust
                  ))
    (native-inputs (list                  clang-toolchain
                  pkg-config
                  llvm))
    ;;(propagated-inputs (list cargo))
    (license license:gpl3)
    (home-page "https://github.com/Riey/kime";)
    (synopsis "kime is an input method with gtk3 gtk4 qt5 qt6 xim
wayland support")
    (description "kime is an input method framework written in rust,
supporting gtk3, gtk4, qt5, qt6, xim, and wayland.")
   ))

kime

--------
Here's a snippet from the successful build log when running the original
scripts/build.sh -ar script directly:

....skip...
cargo build --release -pkime-engine-capi -pkime-check -pkime-indicator
-pkime-candidate-window -pkime-xim -pkime-wayland -pkime Finished
release profile [optimized] target(s) in 0.23s
cp ./target/release/libkime_engine.so /home/orka/src/kime/build/out
cp ./target/release/kime-check /home/orka/src/kime/build/out
cp ./target/release/kime-candidate-window /home/orka/src/kime/build/out
cp ./target/release/kime-indicator /home/orka/src/kime/build/out
cp ./target/release/kime-xim /home/orka/src/kime/build/out
cp ./target/release/kime-wayland /home/orka/src/kime/build/out
cp ./target/release/kime /home/orka/src/kime/build/out
cp src/engine/cffi/kime_engine.h /home/orka/src/kime/build/out
cp src/engine/cffi/kime_engine.hpp /home/orka/src/kime/build/out
cp docs/CHANGELOG.md /home/orka/src/kime/build/out
cp LICENSE /home/orka/src/kime/build/out
cp  /home/orka/src/kime/build/out
cp  /home/orka/src/kime/build/out
cp  /home/orka/src/kime/build/out
cp -R res/default_config.yaml res/icons res/kime.desktop
res/kime-xdg-autostart /home/orka/src/kime/build/out
mkdir -pv build/cmake
echo Build gtk qt immodules... Build gtk qt immodules...
cd build/cmake
cmake ../../src -DCMAKE_BUILD_TYPE=Release -DENABLE_GTK3=ON
-DENABLE_GTK4=ON -DENABLE_QT5=ON -DENABLE_QT6=ON -- Configuring done
-- Generating done -- Build files have been written to:
/home/orka/src/kime/build/cmake
make -j4 [ 50%] Built target kime-gtk4 [100%] Built target kime-gtk3
cp lib/libkime-gtk3.so lib/libkime-gtk4.so
/home/orka/src/kime/build/outNOTICE.mdREADME.mdREADME.ko.md

And here is uncommented version of kime.scm error (uncomment below part
from kime.scm )

((assoc-ref cargo:%standard-phases 'configure) #:inputs inputs)

error: in phase 'cargo-build': uncaught exception: wrong-type-arg
"string-prefix?" "Wrong type argument in position ~A (expecting ~A):
~S" (2 "string" #f) (#f) phase `cargo-build' failed after 0.0 seconds
Backtrace: ....
ice-9/boot-9.scm:1685:16: In procedure raise-exception: In procedure
string-prefix?: Wrong type argument in position 2 (expecting string):
#f build process 6 exited with status 256

==========================================


Any help would be appreciated! Thanks in advance.

Reply via email to