unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* Minimal working examples of packages for experimentation?
@ 2023-02-27 19:26 Rodrigo Morales
  2023-02-27 21:33 ` Jelle Licht
  0 siblings, 1 reply; 2+ messages in thread
From: Rodrigo Morales @ 2023-02-27 19:26 UTC (permalink / raw)
  To: help-guix

Table of Contents
_________________

1. The context
2. What I've tried
3. What I'm looking for


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

  I'm trying to write the simplest package definition that does nothing
  in order to be able to generate multiple generations on the fly and
  experiment with the `guix package' flags that act on generations.

  I asked the same question in <irc://irc.libera.chat/guix> and someone
  recommended me using the `my-hello' package shown as an example in
  (guix-cookbook) GUIX_PACKAGE_PATH. I replied to him that I didn't want
  to use that definition because it downloads a file and performs some
  compilation steps and I was looking for something simpler. The same
  user replied "you could copy the sources to a local directory, and
  edit the file description so it's url-fetch method and the uri is the
  absolute path to where the pkg is.". I haven't found examples on this,
  so I thought it would be difficult to do it.

  I found several examples on using `url-fetch', so I decided to write a
  package that downloads a single small file from the Internet
  (e.g. <https://www.gnu.org/graphics/heckert_gnu.transp.small.png> )
  and install it under a directory. This is what I tried to write but
  with no avail. The next section shows what I tried.


2 What I've tried
=================

  The following is the package that I wrote.

  ,----
  | (define-module (my-simple)
  |   #:use-module (guix licenses)
  |   #:use-module (guix packages)
  |   #:use-module (guix gexp)
  |   #:use-module (guix build-system trivial)
  |   #:use-module (guix download))
  |
  | (define-public my-simple-1
  |   (package
  |    (name "my-simple-1")
  |    (version "2.10")
  |    (source (origin
  |             (method url-fetch)
  |             (uri "
https://www.gnu.org/graphics/heckert_gnu.transp.small.png")
  |             (sha256 (base32
"1686w7x3qk85i5693nrj7lbdh64232fdsqd5rgxgijv1y39rldbr"))))
  |    (build-system trivial-build-system)
  |    (synopsis "My synopsis")
  |    (description "My description")
  |    (home-page "https://example.org/")
  |    (license gpl3+)))
  `----

  If I try to install the package I get the following
  error. Fortunately, it shows that there's a build log.

  ,----
  | export GUIX_PACKAGE_PATH=~/my-packages
  | guix package -i my-simple-1
  | echo Exit code: $?
  `----

  ,----
  | The following package will be installed:
  |    my-simple-1 2.10
  |
  | substitute:
substitute: [Kupdating substitutes from 'https://ci.guix.gnu.org'...   0.0%
substitute: [Kupdating substitutes from 'https://ci.guix.gnu.org'... 100.0%
  | substitute:
substitute: [Kupdating substitutes from 'https://bordeaux.guix.gnu.org'...
  0.0%
substitute: [Kupdating substitutes from 'https://bordeaux.guix.gnu.org'...
100.0%
  | The following derivations will be built:
  |   /gnu/store/lsqc0zjvqmnc8vbkk36g9jy5bcnmk455-profile.drv
  |   /gnu/store/a1cxm06cdacqry9x0c14pnb4s491b6z9-my-simple-1-2.10.drv
  |
  | building
/gnu/store/a1cxm06cdacqry9x0c14pnb4s491b6z9-my-simple-1-2.10.drv...
  | builder for
`/gnu/store/a1cxm06cdacqry9x0c14pnb4s491b6z9-my-simple-1-2.10.drv' failed
to produce output path
`/gnu/store/a8p80lxgcar332ln81ss6pl9xr0wajsh-my-simple-1-2.10'
  | build of
/gnu/store/a1cxm06cdacqry9x0c14pnb4s491b6z9-my-simple-1-2.10.drv failed
  | View build log at
'/var/log/guix/drvs/a1/cxm06cdacqry9x0c14pnb4s491b6z9-my-simple-1-2.10.drv.gz'.
  | cannot build derivation
`/gnu/store/lsqc0zjvqmnc8vbkk36g9jy5bcnmk455-profile.drv': 1 dependencies
couldn't be built
  | guix package: error: build of
`/gnu/store/lsqc0zjvqmnc8vbkk36g9jy5bcnmk455-profile.drv' failed
  | Exit code: 1
  `----

  When I try to read the log file, it is empty.

  ,----
  | echo 'foo'
  | zcat
/var/log/guix/drvs/a1/cxm06cdacqry9x0c14pnb4s491b6z9-my-simple-1-2.10.drv.gz
  | echo 'bar'
  `----

  ,----
  | foo
  | bar
  `----


3 What I'm looking for
======================

  1. Why the package that I wrote failing? How could I fix it?
  2. Do you know simpler package definitions (aka minimal working
     examples) that I could use for experimenting?

  (This is an example of [The XY problem], question 1 is X, question 2
  is Y)


[The XY problem] <https://xyproblem.info>

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

* Re: Minimal working examples of packages for experimentation?
  2023-02-27 19:26 Minimal working examples of packages for experimentation? Rodrigo Morales
@ 2023-02-27 21:33 ` Jelle Licht
  0 siblings, 0 replies; 2+ messages in thread
From: Jelle Licht @ 2023-02-27 21:33 UTC (permalink / raw)
  To: Rodrigo Morales, help-guix

Hello Rodrigo!

Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:

> [snip]

>   The following is the package that I wrote.
>
>   ,----
>   | (define-module (my-simple)
>   |   #:use-module (guix licenses)
>   |   #:use-module (guix packages)
>   |   #:use-module (guix gexp)
>   |   #:use-module (guix build-system trivial)
>   |   #:use-module (guix download))
>   |
>   | (define-public my-simple-1
>   |   (package
>   |    (name "my-simple-1")
>   |    (version "2.10")
>   |    (source (origin
>   |             (method url-fetch)
>   |             (uri "
> https://www.gnu.org/graphics/heckert_gnu.transp.small.png")
>   |             (sha256 (base32
> "1686w7x3qk85i5693nrj7lbdh64232fdsqd5rgxgijv1y39rldbr"))))
>   |    (build-system trivial-build-system)
>   |    (synopsis "My synopsis")
>   |    (description "My description")
>   |    (home-page "https://example.org/")
>   |    (license gpl3+)))
>   `----

> [snip]

> 3 What I'm looking for
> ======================
>
>   1. Why the package that I wrote failing? How could I fix it?

Looking at `info "(guix) Build Systems"'[0], in the blurb about the
trivial-build-system:

--8<---------------cut here---------------start------------->8---
     This build system requires a ‘#:builder’ argument.  This argument
     must be a Scheme expression that builds the package output(s)—as
     with ‘build-expression->derivation’ (*note
     ‘build-expression->derivation’: Derivations.).
--8<---------------cut here---------------end--------------->8---

The reason your package fails to build, is that it doesn't provide such
a #:builder argument. This argument is also responsible for creating the
actual output, which can be a file or directory.

The simplest snippet I can think of for making your package "work":

--8<---------------cut here---------------start------------->8---
(define-public my-simple-1
  (package
    ; .. existing stuff
    (arguments (list #:builder #~(mkdir #$output)))))
--8<---------------cut here---------------end--------------->8---

Note that this simply creates the output directory, and does nothing
else.

What may seem a bit misleading here is that "build expressions" have
mostly been ported to this hip thing called G-Expressions (see `info
"(guix) G-Expressions"' [1]).

>   2. Do you know simpler package definitions (aka minimal working
>      examples) that I could use for experimenting?

Simple does not always imply easy. If we're talking about an easy to use
build system, I think the `copy-build-system' could work, as does the
gnu-build-system as it allows you to play with the moving parts without
having to supply all of these moving parts yourself :).

A package that uses the trivial-build-system that does slightly more is
`inxi-minimal', which you can find by issuing a `guix edit inxi-minimal'.

HTH!
 - Jelle

[0]: https://guix.gnu.org/manual/devel/en/html_node/Build-Systems.html#index-trivial_002dbuild_002dsystem
[1]: https://guix.gnu.org/manual/devel/en/html_node/G_002dExpressions.html


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

end of thread, other threads:[~2023-02-27 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-27 19:26 Minimal working examples of packages for experimentation? Rodrigo Morales
2023-02-27 21:33 ` Jelle Licht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).