all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Newbie: Define package that downloads multiple files from an open directory
@ 2023-05-26  5:22 Rodrigo Morales
  2023-05-26 10:14 ` Simon Tournier
  0 siblings, 1 reply; 2+ messages in thread
From: Rodrigo Morales @ 2023-05-26  5:22 UTC (permalink / raw)
  To: help-guix

Table of Contents
_________________

1. The context
2. What I know
3. The question
4. Additional information about enquiry


1 The context
=============

  Suppose there's an open directory publicly available on the
  Internet. I want to define a Guix package that downloads multiple
  files from that directory.


2 What I know
=============

  I know how to define a package that downloads a single file.

  Let's consider [this] directory for our experimentation (I chose it
  because it has relatively small files). Suppose I want to download the
  file `blindtext.dtx' and make it available in
  `~/.guix-profile/share'. My package definition would look as it
  follows.

  ,----
  | cat ~/my/git-repos/guix-packages/my/test.scm
  `----

  ,----
  | (define-module (my test)
  |   #:use-module (guix licenses)
  |   #:use-module (guix packages)
  |   #:use-module (guix download)
  |   #:use-module (guix build-system copy))
  |
  | (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/"))))))
  `----

  I would install that package with the following command.

  ,----
  | guix package --no-substitutes -L ~/my/git-repos/guix-packages -i
my-package-1
  `----

  ,----
  | The following package will be installed:
  |    my-package-1 1.0
  |
  | hint: Consider setting the necessary environment variables by running:
  |
  |      GUIX_PROFILE="/home/rdrg/.guix-profile"
  |      . "$GUIX_PROFILE/etc/profile"
  |
  | Alternately, see `guix package --search-paths -p
  | "/home/rdrg/.guix-profile"'.
  |
  `----

  The file gets created in the following path which is symlinked to the
  following file in `/gnu/store'.

  ,----
  | realpath ~/.guix-profile/share/blindtext.dtx
  `----

  ,----
  | /gnu/store/mmqc8wav2jj3m3harisvawl1r881glpv-my-package-1-1.0/share/blindtext.dtx
  `----


[this] <http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/>


3 The question
==============

  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?


4 Additional information about enquiry
======================================

  Please ignore the following three points:

  + the parent directory of
    <http://tug.ctan.org/tex-archive/macros/latex/contrib/blindtext/>
    has a ZIP file which is the compressed version of that directory
  + Guix already has a package for `blindtext' called
    `texlive-latex-blindtext'
  + Guix has some utilities for handling packages from CTAN or Tex Live
    (see <https://issues.guix.gnu.org/60820#3> which mentions
    `simple-texlive-package')

  In other words, consider that the directory we are using for our
  experimentation is an arbitrary directory on the Internet and that
  there's no way of downloading the compressed version of that
  directory. I'm poing this out because I'm more interessted in learning
  how to define a package that downlaods multiple files instead of
  finding a workaround that installs `blindtext'.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Newbie: Define package that downloads multiple files from an open directory
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Tournier @ 2023-05-26 10:14 UTC (permalink / raw)
  To: Rodrigo Morales, help-guix

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-26 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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.