help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Let's share examples of simplistic and useless package definitions


From: Rodrigo Morales
Subject: Let's share examples of simplistic and useless package definitions
Date: Fri, 26 May 2023 18:59:33 +0000

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>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]