Build-phase can't find my own custom packaged dependency, not sure where to go from here

So i’m trying to package a program called qcma. I managed to package it in the past with nix, but i can’t seem to get it to work as a Guix derivation and i’m running out of ideas. The program depends on a custom library that i managed to package succesfully, but during the build phase of qcma itself it complains about not being able to find the libvitamtp dependency, eventhough i’ve listed it as an input and native-input. Here are the derivations:

(define-module (config packages qcma)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system qt)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages video)
  #:use-module (gnu packages xml))

(define-public libvitamtp
  (package
   (name "libvitamtp")
   (version "2.5.10")
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/codestation/vitamtp")
                  (commit (string-append "v" version))))
            (file-name (git-file-name name version))
            (sha256
             (base32 "0np60v6c8a3v4fm9fba51a6g1bh89r9v5drr32iwvq2h64gykk8q"))))
   (build-system gnu-build-system)
   (native-inputs (list pkg-config
                        libxml2
                        libusb
                        libtool
                        automake
                        autoconf
                        gettext-minimal))
   (home-page "https://github.com/codestation/vitamtp")
   (synopsis "Library to interact with Vita's USB MTP protocol.")
   (description "libvitamtp is a library based off of libMTP that does low level USB communications with the Vita.
It can read and recieve MTP commands that the Vita sends, which are a proprietary set of commands that is based
on the MTP open standard.")
   (license license:gpl3)))

;; Can't get qcma package to work right now, it gives an error about not being able to find libvitamtp in the build phase,
;; eventhough it is listed as a dependency. I'll give this another try later.
(define-public qcma
  (package
   (name "qcma")
   (version "0.5.1")
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/codestation/qcma")
                  (commit (string-append "v" version))))
            (file-name (git-file-name name version))
            (sha256
             (base32 "14jb3p9ill5hqgzxx15l8dv34gpc3dsmvcc1yxrv8jdi7s8zg0nj"))))
   (build-system gnu-build-system)
   (inputs (list libvitamtp
                 libnotify
                 ffmpeg))
   (native-inputs (list pkg-config
                        libvitamtp
                        qttools
                        qtbase))
   (arguments
    (list #:phases
          #~(modify-phases %standard-phases
                           (replace 'configure
                                    (lambda _ (invoke "lrelease" "common/resources/translations/qcma_ja.ts")
                                            (substitute* "common/common.pro"
                                                         (("PKGCONFIG += libvitamtp")
                                                          (string-append "PKGCONFIG += " #$libvitamtp)))
                                               (invoke "qmake" "qcma.pro" (string-append "PREFIX=" #$output)))))))
   (home-page "https://github.com/codestation/qcma")
   (synopsis "Cross-platform content manager assistant for the PS Vita.")
   (description "QCMA is a cross-platform application to provide an open source implementation of the original
Content Manager Assistant that comes with the PS Vita. QCMA is meant to be compatible with Linux, Windows and MacOS.")
   (license license:gpl3)))                 

You’ll notice i tried messing around with the PKGCONFIG variable inside of common/common.pro, cause that’s the file where the build process seems to get stuck on, and PKGCONFIG is the only place in the file that i can tell where libvitamtp is mentioned at all. This is the error that the build process spits out:

Project ERROR: libvitamtp development package not found

I was wondering if there’s someone here who might have some experience with guix packaging that knows what’s going on here, cause so far i haven’t been able to figure out why it can’t find the dependency.

It may need to be a native input. Do you know the difference?

It shouldn’t be both

Yeah i know the difference. The reason i put it in both fields is because from my understanding the library is also a runtime dependency, but it’s been a while since i packaged it in nix and i basically just tried translating what i did there over to guix. For what it’s worth i did try removing it from the inputs field but it doesn’t make a difference.

If it’s a runtime dependency, then it needs to be propagated. Read through the Guix cookbook.

It also helps to think of a similar package, then run guix edit $packgename which pops open your $EDITOR to that package definition. There are tons of examples

Isn’t the difference between inputs and propagated-inputs that the packages also get installed into the profile? I don’t think that’s necessary for a library.

If you run ldd on the bin output, it will make it clear which library it expects to find.

It’s been awhile since I’ve built packages.

Propagated will make it available at the top-level profile where the package is installed

Just wanted to update this post for the sake of completeness and in case it helps someone else in the future. Someone on Reddit was kind enough to help me figure out what was wrong, and it turned out that the problem wasn’t directly related to the qcma derivation, but rather the libvitamtp derivation. It turned out both libxml2 and libusb had to be propagated-inputs, instead of native inputs. After that libvitamtp dependency was recognized by the qmake build process. Aside from that though the qcma derivation also still required quite a few tweaks. Also had to downgrade qcma because with the newer versions the ps vita would keep giving errors when trying to copy files to the pc. Will probably have to open an issue on the projects’ github for that. Well anyway, here are the final working derivations:

(define-module (config packages qcma)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system qt)
  #:use-module (guix gexp)
  #:use-module (guix git-download)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages gnome)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages libusb)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages qt)
  #:use-module (gnu packages video)
  #:use-module (gnu packages xml))

(define-public libvitamtp
  (package
   (name "libvitamtp")
   (version "2.5.10")
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/codestation/vitamtp")
                  (commit (string-append "v" version))))
            (file-name (git-file-name name version))
            (sha256
             (base32 "0np60v6c8a3v4fm9fba51a6g1bh89r9v5drr32iwvq2h64gykk8q"))))
   (build-system gnu-build-system)
   (native-inputs (list pkg-config
                        libtool
                        automake
                        autoconf
                        gettext-minimal))
   (propagated-inputs (list libxml2
                            libusb))
   (arguments
    (list #:phases
          #~(modify-phases %standard-phases
                           (add-after 'install 'install-udev-rules
                                      (lambda _
                                        (mkdir-p (string-append #$output "/lib/udev/rules.d"))
                                        (copy-file "debian/libvitamtp5.udev" (string-append #$output "/lib/udev/rules.d/60-psvita.rules")))))))
   (home-page "https://github.com/codestation/vitamtp")
   (synopsis "Library to interact with Vita's USB MTP protocol.")
   (description "libvitamtp is a library based off of libMTP that does low level USB communications with the Vita.
It can read and recieve MTP commands that the Vita sends, which are a proprietary set of commands that is based
on the MTP open standard.")
   (license license:gpl3)))

(define-public qcma
  (package
   (name "qcma")
   (version "0.4.1") ;; Staying on 0.4.1 for now, as both 0.5.0 as well as 0.5.1 have an issue where the Vita can't copy to PC (error C0-14266-9).
   (source (origin
            (method git-fetch)
            (uri (git-reference
                  (url "https://github.com/codestation/qcma")
                  (commit (string-append "v" version))))
            (file-name (git-file-name name version))
            (sha256
             (base32 "15wrjg7xjnbzrl2r2z90nqvd4ifrsn4p8kvd1yn58s3i9p1v17kr"))))
   (build-system qt-build-system)
   (inputs (list libvitamtp
                 libnotify
                 ;; ffmpeg ;; Can be used with newer versions of qcma, but 0.4.1 is not compatible with newer versions of ffmpeg.
                 ))
   (native-inputs (list pkg-config
                        libvitamtp
                        qttools-5
                        qtbase-5))
   (arguments
    (list #:qtbase qtbase
          #:tests? #f ;; There are no tests for this package.
          #:modules '((guix build qt-build-system)
                      ((guix build gnu-build-system) #:prefix gnu:)
                      (guix build utils))
          #:phases
          #~(modify-phases %standard-phases
                           (replace 'configure
                                    (lambda _
                                      (for-each (lambda (ts) (invoke "lrelease" ts))
                                                (find-files "common/resources/translations"
                                                            "\\.ts$"))
                                      (invoke "qmake" "qcma.pro" (string-append "PREFIX=" #$output) "CONFIG+=DISABLE_FFMPEG")))
                           (replace 'build (assoc-ref gnu:%standard-phases 'build))
                           (replace 'install (assoc-ref gnu:%standard-phases 'install)))))
                           (home-page "https://github.com/codestation/qcma")
                           (synopsis "Cross-platform content manager assistant for the PS Vita.")
                           (description "QCMA is a cross-platform application to provide an open source implementation of the original
Content Manager Assistant that comes with the PS Vita. QCMA is meant to be compatible with Linux, Windows and MacOS.")
                           (license license:gpl3)))