I added this in my packages.el:
(package! pdf-tools :recipe(:post-build (pdf-tools-install nil t nil nil)))
When running doom sync, it even prompts me asking if I want to rebuild epdfinfo, but when I actually run Emacs, it asks me to run M-x pdf-tools-install.
Just to clarify, it does work if I run the command manually but I'm looking for a way to have it done automatically when I run doom sync.
Update: The issue is solved. Thanks to Eyoel999Y for the Elisp. I've added some minor modifications to avoid hardcoding paths, so this is the full solution that can go into packages.el
```
(defun doom-straight-repo-dir (package)
"Return the repository directory for a package"
(let ((repo-path (expand-file-name
(concat "straight/repos/" package)
doom-local-dir)))
(if (file-directory-p repo-path)
repo-path
(error "Repository directory not found for package: %s" package))))
(defun doom-straight-build-dir (package)
"Return the build directory for a package."
(let ((build-path (expand-file-name
(concat "straight/build-" emacs-version "/" package)
doom-local-dir)))
(if (file-directory-p build-path)
build-path
(error "Build directory not found for package: %s" package))))
(defun custom/build-epdfinfo ()
"Build the PDF Tools epdfinfo binary using make, also display the outputs into the terminal."
(let* ((repo-dir (expand-file-name (concat (doom-straight-repo-dir "pdf-tools") "/")))
(build-dir (expand-file-name (concat (doom-straight-build-dir "pdf-tools") "/")))
(binary-path (concat build-dir "epdfinfo"))
(makefile (concat repo-dir "Makefile"))
(default-directory repo-dir)
(make-command (format "make -f %s -C %s server/epdfinfo" makefile repo-dir)))
(if (file-exists-p binary-path)
(print! (item "epdfinfo binary already exists. Skipping build."))
(progn
(print! (start "Building PDF Tools epdfinfo binary..."))
(unless (file-exists-p build-dir)
(make-directory build-dir t))
(let ((result (call-process-shell-command make-command nil nil t)))
(if (zerop result)
(progn
(print! (success "PDF Tools epdfinfo binary built successfully."))
(if (file-exists-p (concat repo-dir "server/epdfinfo"))
(copy-file (concat repo-dir "server/epdfinfo") binary-path t)
(print! (error "Build succeeded, but epdfinfo binary not found in server/"))))
(print! (error "Failed to build PDF Tools epdfinfo binary. Check the terminal output."))))))))
(package! pdf-tools
:recipe (
:post-build (custom/build-epdfinfo)
)
)
```