From: Rodrigo Morales <moralesrodrigo1100@gmail.com>
To: help-guix@gnu.org
Subject: Let's share examples of simplistic and useless package definitions
Date: Fri, 26 May 2023 18:59:33 +0000 [thread overview]
Message-ID: <CAGxMbPZN21Skh9QvTH2Y=XnEVyNo34pXEnRBb=mYwiiC0c6H8A@mail.gmail.com> (raw)
Table of Contents
_________________
1. The context
.. 1. Package no. 1: Create `%output' directory
.. 2. Package no. 2: Copy a local file
2. The enquiries
1 The context
=============
As part of my learning journey with Guix, I'm trying to write
simplistic and useless package definitions in order to experiment with
them and get more familiar with the internals with Guix. I've been
able to come up with the following packages.
1.1 Package no. 1: Create `%output' directory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following package creates the output directory and does nothing
else.
,----
| (define-module (my test)
| #:use-module (guix packages)
| #:use-module (guix build-system trivial))
|
| (define-public my-package-1
| (package
| (name "my-package-1")
| (version "50.0")
| (home-page #f)
| (synopsis #f)
| (description #f)
| (license #f)
| (source #f)
| (build-system trivial-build-system)
| (arguments
| `(#:modules ((guix build utils))
| #:builder
| (begin
| (use-modules (guix build utils))
| (format #t "~a~%" "foo 1")
| (format #t "~a~%" %output)
| (format #t "~a~%" "foo 2")
| (mkdir %output))))))
`----
,----
| guix package -v3 --no-substitutes -L ~/my/git-repos/guix-packages
-i my-package-1
| echo Exit code: $?
`----
,----
| The following package will be installed:
| my-package-1 50.0
|
| The following derivations will be built:
| /gnu/store/d5882590j5w74gwyzl784609wp08hjnl-profile.drv
| /gnu/store/fh51w90hsp5pn67wz2k6a14y3ix96kdq-my-package-1-50.0.drv
| The following profile hooks will be built:
| /gnu/store/1mrv6rb283vhjd0kxvbzngy9bdh4nyr5-glib-schemas.drv
| /gnu/store/gaz7c0ivgz4ygyg6m0805s4bhv4n09p9-gdk-pixbuf-loaders-cache-file.drv
| /gnu/store/hhqw7ykgx3hk2r2p1b4mb5bwbi9syz5k-xdg-mime-database.drv
| /gnu/store/hnslzij7j5772zdypb5rxcwzjlm2snj4-ca-certificate-bundle.drv
| /gnu/store/j797wxpm81ajszfx08j7yq7643dmx3cv-gtk-im-modules.drv
| /gnu/store/jk0qiy0bmy3jp99jhj6bvinly6an4rg4-gtk-icon-themes.drv
| /gnu/store/phf48hr7xa7smgc7q4zcksc4nwxi622v-xdg-desktop-database.drv
| /gnu/store/qissga15w17swkcdmjfhxnf086nl0gad-info-dir.drv
| /gnu/store/x5zxihym559mqhmkbnz0jpxr9ywfyk84-fonts-dir.drv
| /gnu/store/xc6nwqvn0ap15ajp5lw9k1k1kf2fc1va-emacs-subdirs.drv
| building /gnu/store/fh51w90hsp5pn67wz2k6a14y3ix96kdq-my-package-1-50.0.drv...
| foo 1
| /gnu/store/i48wxgjpvskkmvpkgscik3vbmsqn8z27-my-package-1-50.0
| foo 2
| successfully built
/gnu/store/fh51w90hsp5pn67wz2k6a14y3ix96kdq-my-package-1-50.0.drv
| building CA certificate bundle...
| successfully built
/gnu/store/hnslzij7j5772zdypb5rxcwzjlm2snj4-ca-certificate-bundle.drv
| listing Emacs sub-directories...
| successfully built
/gnu/store/xc6nwqvn0ap15ajp5lw9k1k1kf2fc1va-emacs-subdirs.drv
| building fonts directory...
| successfully built /gnu/store/x5zxihym559mqhmkbnz0jpxr9ywfyk84-fonts-dir.drv
| generating GdkPixbuf loaders cache...
| successfully built
/gnu/store/gaz7c0ivgz4ygyg6m0805s4bhv4n09p9-gdk-pixbuf-loaders-cache-file.drv
| generating GLib schema cache...
| successfully built
/gnu/store/1mrv6rb283vhjd0kxvbzngy9bdh4nyr5-glib-schemas.drv
| creating GTK+ icon theme cache...
| successfully built
/gnu/store/jk0qiy0bmy3jp99jhj6bvinly6an4rg4-gtk-icon-themes.drv
| building cache files for GTK+ input methods...
| successfully built
/gnu/store/j797wxpm81ajszfx08j7yq7643dmx3cv-gtk-im-modules.drv
| building directory of Info manuals...
| successfully built /gnu/store/qissga15w17swkcdmjfhxnf086nl0gad-info-dir.drv
| building XDG desktop file cache...
| successfully built
/gnu/store/phf48hr7xa7smgc7q4zcksc4nwxi622v-xdg-desktop-database.drv
| building XDG MIME database...
| successfully built
/gnu/store/hhqw7ykgx3hk2r2p1b4mb5bwbi9syz5k-xdg-mime-database.drv
| building profile with 19 packages...
| successfully built /gnu/store/d5882590j5w74gwyzl784609wp08hjnl-profile.drv
| 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"'.
|
| Exit code: 0
`----
1.2 Package no. 2: Copy a local file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following package copies a local file to `~/.guix-profile/share'.
,----
| echo a > ~/e/foo.txt
`----
,----
| (define-module (my test)
| #:use-module (guix gexp)
| #:use-module (guix packages)
| #:use-module (guix build-system trivial))
|
| (define-public my-package-1
| (package
| (name "my-package-1")
| (version "53.0")
| (home-page #f)
| (synopsis #f)
| (description #f)
| (license #f)
| (source (local-file (string-append "/home/rdrg/e/foo.txt")))
| (build-system trivial-build-system)
| (arguments
| `(#:modules ((guix build utils))
| #:builder
| (begin
| (use-modules (guix build utils))
| (let* ((dir (string-append %output "/share"))
| (file (string-append dir "/foo.txt")))
| (mkdir-p dir)
| (copy-file (assoc-ref %build-inputs "source") file)
| (format #t "~a~%" "foo 1")
| (format #t "%build-inputs: ~a~%" %build-inputs)
| (format #t "%output: ~a~%" %output)
| (format #t "dir: ~a~%" dir)
| (format #t "file: ~a~%" file)
| (format #t "~a~%" "foo 2")))))))
`----
,----
| guix package -v3 --no-substitutes -L ~/my/git-repos/guix-packages
-i my-package-1
| echo Exit code: $?
`----
,----
| The following package will be installed:
| my-package-1 53.0
|
| The following derivations will be built:
| /gnu/store/n528dak6y0f9r9zdbd86drysphgyl21h-profile.drv
| /gnu/store/pck6w1v3shagpmhw9xzhgjrbz3s09saw-my-package-1-53.0.drv
| The following profile hooks will be built:
| /gnu/store/0w41r9qzf1y0yymx4ym7zmx3lv4r46ds-ca-certificate-bundle.drv
| /gnu/store/2qd0kypbs5nb7ma4sdgd3iffj23qfhmb-glib-schemas.drv
| /gnu/store/72wpyxjxzdiy5gjw9ji0bwlprcf76407-gtk-icon-themes.drv
| /gnu/store/a18j6s911nn46a5d7r2902q32kbvf6wy-xdg-desktop-database.drv
| /gnu/store/hl2zcs4d79d9xb2x2wwih27hhbwwmpqn-info-dir.drv
| /gnu/store/pgqb8kb71jrplwa7dmaz0rrh6h1i20bl-xdg-mime-database.drv
| /gnu/store/w3mcyvm92kn15mr7hcw1mgb2687jhpkv-fonts-dir.drv
| /gnu/store/x3ams39s13ykak6ghg3knbyn4rnpw07b-gtk-im-modules.drv
| /gnu/store/xmfnb64dxknbnq16rg8sf3wxmri99w9g-gdk-pixbuf-loaders-cache-file.drv
| /gnu/store/yh5c44v3pdf1l1j6a9hjqa7l0wacighg-emacs-subdirs.drv
| building /gnu/store/pck6w1v3shagpmhw9xzhgjrbz3s09saw-my-package-1-53.0.drv...
| foo 1
| %build-inputs: ((source .
/gnu/store/bzbxn3r9gq7rhqm565rw9fcy88b8gryy-foo.txt))
| %output: /gnu/store/hf37gi60wq46qlgzks9hfxln3hx77xms-my-package-1-53.0
| dir: /gnu/store/hf37gi60wq46qlgzks9hfxln3hx77xms-my-package-1-53.0/share
| file: /gnu/store/hf37gi60wq46qlgzks9hfxln3hx77xms-my-package-1-53.0/share/foo.txt
| foo 2
| successfully built
/gnu/store/pck6w1v3shagpmhw9xzhgjrbz3s09saw-my-package-1-53.0.drv
| building CA certificate bundle...
| successfully built
/gnu/store/0w41r9qzf1y0yymx4ym7zmx3lv4r46ds-ca-certificate-bundle.drv
| listing Emacs sub-directories...
| successfully built
/gnu/store/yh5c44v3pdf1l1j6a9hjqa7l0wacighg-emacs-subdirs.drv
| building fonts directory...
| successfully built /gnu/store/w3mcyvm92kn15mr7hcw1mgb2687jhpkv-fonts-dir.drv
| generating GdkPixbuf loaders cache...
| successfully built
/gnu/store/xmfnb64dxknbnq16rg8sf3wxmri99w9g-gdk-pixbuf-loaders-cache-file.drv
| generating GLib schema cache...
| successfully built
/gnu/store/2qd0kypbs5nb7ma4sdgd3iffj23qfhmb-glib-schemas.drv
| creating GTK+ icon theme cache...
| successfully built
/gnu/store/72wpyxjxzdiy5gjw9ji0bwlprcf76407-gtk-icon-themes.drv
| building cache files for GTK+ input methods...
| successfully built
/gnu/store/x3ams39s13ykak6ghg3knbyn4rnpw07b-gtk-im-modules.drv
| building directory of Info manuals...
| successfully built /gnu/store/hl2zcs4d79d9xb2x2wwih27hhbwwmpqn-info-dir.drv
| building XDG desktop file cache...
| successfully built
/gnu/store/a18j6s911nn46a5d7r2902q32kbvf6wy-xdg-desktop-database.drv
| building XDG MIME database...
| successfully built
/gnu/store/pgqb8kb71jrplwa7dmaz0rrh6h1i20bl-xdg-mime-database.drv
| building profile with 19 packages...
| successfully built /gnu/store/n528dak6y0f9r9zdbd86drysphgyl21h-profile.drv
| 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"'.
|
| Exit code: 0
`----
2 The enquiries
===============
1. I'm now trying to write a package that creates a temporary file
containing the letter "a" with "echo > /a/temporary/location.txt"
and makes it available at =~/.guix-profile/share=. What would this
package look like?
2. Could you share other package definitions that have the same level
of simplicity?
I opened [a thread] on this topic 3 months ago and someone replied,
but I didn't have the enough knowledge to understand his
response. Today, the same question popped up in my mind and I finally
understood it so I wrote the packages shown above.
[a thread]
<https://lists.gnu.org/archive/html/help-guix/2023-02/msg00146.html>
next reply other threads:[~2023-05-26 19:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 18:59 Rodrigo Morales [this message]
2023-05-28 19:40 ` Let's share examples of simplistic and useless package definitions Skyler Ferris
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='CAGxMbPZN21Skh9QvTH2Y=XnEVyNo34pXEnRBb=mYwiiC0c6H8A@mail.gmail.com' \
--to=moralesrodrigo1100@gmail.com \
--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.