all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: Rodrigo Morales <moralesrodrigo1100@gmail.com>, help-guix@gnu.org
Subject: Re: Newbie: Define package that downloads multiple files from an open directory
Date: Fri, 26 May 2023 12:14:11 +0200	[thread overview]
Message-ID: <87ttvztn64.fsf@gmail.com> (raw)
In-Reply-To: <CAGxMbPZu4EG7YKGqoF9cOFbqtjWos0ukw-wE1Rvm03w5aYDReg@mail.gmail.com>

Hi,

On ven., 26 mai 2023 at 05:22, Rodrigo Morales <moralesrodrigo1100@gmail.com> wrote:

>   | (define-public my-package-1
>   |   (package
>   |    (name "my-package-1")
>   |    (version "1.0")
>   |    (home-page "My home-page")
>   |    (synopsis "My synopsis")
>   |    (description "My description")
>   |    (license gpl3+)
>   |    (source
>   |     (origin
>   |      (method url-fetch)
>   |      (uri "http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/blindtext.dtx")
>   |      (sha256
>   |       (base32
>   |        "10sfm4648v1ywki639jsl5darkcil1is462w0v65xxr75k4l1ywl"))))
>   |    (build-system copy-build-system)
>   |    (arguments
>   |     '(#:install-plan
>   |       '(("blindtext.dtx" "share/"))))))
>   `----

[...]

>   Let's suppose I want to define a single Guix package that downloads
>   the files `blindtext.dtx' and `blindtext.ins' (that is, two files
>   instead of one) and makes them available at
>   `~/.guix-profile/share'. What would the package definition look like?

You could add an ’inputs’ that is an ’origin’ with the file you want.
Something like:

--8<---------------cut here---------------start------------->8---
    (arguments
     `(#:install-plan
       '(("blindtext.dtx" "share/"))
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'add-ins
           (lambda* (#:key outputs inputs #:allow-other-keys)
             (let ((out (string-append (assoc-ref outputs "out") "/share/")))
               (mkdir-p out)
               (copy-file (assoc-ref inputs "ins")
                          (string-append out "/blindtext.ins"))))))))
    (inputs
     `(("ins" ,(origin
                 (method url-fetch)
                 (uri "http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/blindtext.ins")
                 (sha256
                  (base32
                   "1jfcyz6dw6q65b4hxi39917i9i5lkh3mh8v9zhpn4qqzgc1yj2bp"))))))))
--8<---------------cut here---------------end--------------->8---

and then,

 --8<---------------cut here---------------start------------->8---
$ tree $(guix build -L /tmp/pkg my-package-1)
/gnu/store/3l2r0sc93dii3j9clfgfwv4j3gnh3ynh-my-package-1-1.0
└── share
    ├── blindtext.dtx
    └── blindtext.ins

2 directories, 2 files
--8<---------------cut here---------------end--------------->8---

However, since it looks like TeXLive packages, you might be interested
by ’simple-texlive-package’ from (gnu packages tex).

--8<---------------cut here---------------start------------->8---
(define* (simple-texlive-package name locations hash
                                 #:key trivial?)
  "Return a template for a simple TeX Live package with the given NAME,
downloading from a list of LOCATIONS in the TeX Live repository, and expecting
the provided output HASH.  If TRIVIAL? is provided, all files will simply be
copied to their outputs; otherwise the TEXLIVE-BUILD-SYSTEM is used."
--8<---------------cut here---------------end--------------->8---

Well, this procedure is not exported and it’s probably not exactly what
you want.

Hope that helps,
simon


      reply	other threads:[~2023-05-26 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-26  5:22 Newbie: Define package that downloads multiple files from an open directory Rodrigo Morales
2023-05-26 10:14 ` Simon Tournier [this message]

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=87ttvztn64.fsf@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=help-guix@gnu.org \
    --cc=moralesrodrigo1100@gmail.com \
    /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.