From: "Wiktor Żelazny" <wz@freeshell.de>
To: help-guix@gnu.org
Subject: Reconstructing pandoc share/ path from arch, os, compilerName (and versions) in a package definition with copy-build-system
Date: Fri, 16 Sep 2022 15:21:34 +0200 [thread overview]
Message-ID: <20220916132134.a3odxhicwasf2kk7@nibiowz> (raw)
[-- Attachment #1: Type: text/plain, Size: 3997 bytes --]
(and versions) in a package definition with copy-build-system
Reply-To:
X-PGP-Key: https://freeshell.de/~wz/pubkey.asc
X-PGP-Fingerprint: BDC9 74CD D9C9 BA7D 761A 573D C735 A8C6 AB60 79D5
Hi Guix,
I’m trying to package pandoc-letter [1], which provides a letter
template for Pandoc. The working idea has been to use copy-build-system
and copy template-letter.tex, which is in the pandoc-letter repository
(there are no tarballs), to the directory where Pandoc keeps its default
templates.
For a start, I adapted some code from gnu/packages/vim.scm where an
analogous approach is common for Vim plugins:
(define-public pandoc-letter
(let ((commit "b0fd7342b352ebb87aea17614ec014f68d48747f")
(revision "1"))
(package
(name "pandoc-letter")
(version (string-append "0.0.0-" revision "."
(string-take commit 7)))
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/aaronwolen/pandoc-letter")
(commit commit)))
(file-name (string-append name "-" version "-checkout"))
(sha256
(base32
"1868vs95l0alprvbhwjc60xik2rd7zbpdcysbp2ci81gqffx6r78"))))
(build-system copy-build-system)
(arguments
'(#:install-plan '(("template-letter.tex"
"share/pandoc/data/templates/"))))
(synopsis "Simple letter template for Pandoc")
(description
"This template allows you to write letters in Markdown and convert them to
nice looking PDFs using Pandoc and LaTeX. It accepts arguments used in the
LaTeX letter class, all of which can be specified in a YAML metadata block.
Additional Pandoc/LaTeX options can be configured directly in the metadata
block.")
(home-page "https://github.com/aaronwolen/pandoc-letter")
(license license:gpl3))))
This builds, but the actual templates directory is not
share/pandoc/data/templates, but something more dynamic. For example, on
my machine it is
share/x86_64-linux-ghc-8.10.7/pandoc-2.14.0.3/data/templates.
Apparently, this path is constructed in Paths_pandoc.hs file, with its
contents defined in the pandoc Guix package. The relevant snippet is
datadir :: FilePath
datadir = \"~a/share/\" ++
arch ++ \"-\" ++
os ++ \"-\" ++
compilerName ++ \"-~a/pandoc-~a\"
I don’t know what the motivation for this is. Anyway, I decided to try
to reconstruct the target path, starting from the Pandoc version string
(hidden in this ~a? well, whatever). The definition of the blender
package in Guix gave me some inspiration:
(arguments
(let ((ghc-pandoc-version (version-major+minor (package-version ghc-pandoc))))
'(#:install-plan '(("template-letter.tex"
(string-append "share/pandoc-"
ghc-pandoc-version
"/data/templates/"))))))
While building this, I got the error with the suggestion to load the
(gnu packages haskell-xyz) module, which was promising. Unfortunately,
after fixing that, I’m getting
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure string-append: Wrong type (expecting string): (string-append "share/pandoc-" ghc-pandoc-version "/data/templates/")
Normally, I would inspect the type and value of ghc-pandoc-version at
this point via “print debugging”, but I have no idea how to do that in
Guile in the context of package definition development.
If you could help me to get unstuck, I would be grateful. Or, maybe you
can suggest a wholly different approach, superior to my
path-reconstruction idea.
[1]: https://github.com/aaronwolen/pandoc-letter
Have a nice weekend,
WŻ
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 963 bytes --]
reply other threads:[~2022-09-16 14:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220916132134.a3odxhicwasf2kk7@nibiowz \
--to=wz@freeshell.de \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.