* Newbie user: Feedback on custom package definition
@ 2023-02-28 22:06 Rodrigo Morales
2023-03-01 1:12 ` 宋文武
2023-03-02 15:10 ` Gary Johnson
0 siblings, 2 replies; 6+ messages in thread
From: Rodrigo Morales @ 2023-02-28 22:06 UTC (permalink / raw)
To: help-guix
Table of Contents
_________________
1. The context
2. The package I wrote
3. The questions
1 The context
=============
Newbie user here. I'm learning how to write my own Guix packages. I've
written the following package (please see next section). I have been
able to successfully install it. However, I'm opening this thread so
that any of you could give me some feedback as I'm not experienced
with defining packages.
I'm aware of Emacs being able to download packages from repositories
through the functions defined in `package.el'. However, that package
is not available neither in ELPA nor MELPA, so I thought defining a
GUIX package for it would come in handy.
2 The package I wrote
=====================
,----
| (define-module (my-simple-package)
| #:use-module (guix licenses)
| #:use-module (guix packages)
| #:use-module (guix gexp)
| #:use-module (guix build-system trivial)
| #:use-module (guix git-download))
|
| (define-public my-simple-package-org-recoll
| (package
| (name "my-simple-package-org-recoll")
| (version "1.0")
| (source (origin
| (method git-fetch)
| (uri (git-reference
| (url "https://github.com/alraban/org-recoll")
| (commit "1e21fbc70b5e31b746257c12d00acba3dcc1dd5c")))
| (file-name (git-file-name name version))
| (sha256
| (base32
| "09bixzl8ky7scsahb50wwkdcz335gy257m80z9rpqqhjy6q9023c"))))
| (build-system trivial-build-system)
| (arguments
| (list
| ;; Module that defines install-file. Read "(guix) Build
| ;; Utilities" for more information.
| #:modules `((guix build utils))
| #:builder
| #~(begin
| (use-modules (guix build utils))
| (chdir (assoc-ref %build-inputs "source"))
| (install-file "org-recoll.el"
| (string-append
| #$output
| "/.config/emacs/libs")))))
| (synopsis "My synopsis")
| (description "My description")
| (home-page "https://example.org/")
| (license gpl3+)))
`----
The package I wrote downloads an Emacs package from a git repository
and saves it into a directory
,----
| guix package -i my-simple-package-org-recoll
| echo Exit code: $?
`----
,----
| The following package will be installed:
| my-simple-package-org-recoll 1.0
|
| substitute: updating substitutes from 'https://ci.guix.gnu.org'...
100.0%
| substitute: updating substitutes from 'https://bordeaux.guix.gnu.org'...
100.0%
| The following derivations will be built:
| /gnu/store/zm9hs6wp6v24qy8cr27dgh6ajfixirdf-profile.drv
|
/gnu/store/iqxb2m5lz7k0mj8gklnrxg01q5572w6w-my-simple-package-org-recoll-1.0.drv
|
/gnu/store/a29ymip131j67wq2rhzf9lr9kidqk7fq-my-simple-package-org-recoll-1.0-checkout.drv
|
| building
/gnu/store/a29ymip131j67wq2rhzf9lr9kidqk7fq-my-simple-package-org-recoll-1.0-checkout.drv...
| building
/gnu/store/iqxb2m5lz7k0mj8gklnrxg01q5572w6w-my-simple-package-org-recoll-1.0.drv...
| building CA certificate bundle...
| listing Emacs sub-directories...
| building fonts directory...
| building directory of Info manuals...
| building profile with 2 packages...
| Exit code: 0
`----
By using the following commad, we can see that the file was installed
under my home directory
,----
| find ~/.guix-profile/.config/emacs/libs
| realpath ~/.guix-profile/.config/emacs/libs/org-recoll.el
`----
,----
| /home/rdrg/.guix-profile/.config/emacs/libs
| /home/rdrg/.guix-profile/.config/emacs/libs/org-recoll.el
|
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/.config/emacs/libs/org-recoll.el
`----
By using the following command, we can see the file structure under
`/gnu/store'.
,----
| find
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/
`----
,----
|
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/
|
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/.config
|
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/.config/emacs
|
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/.config/emacs/libs
|
/gnu/store/67sw7m0ww2jw6vz0phhxrj1fphlqc414-my-simple-package-org-recoll-1.0/.config/emacs/libs/org-recoll.el
`----
3 The questions
===============
+ What changes would you do to improve the definition of the package
that I wrote?
+ Do you manage your Emacs packages with GUIX? Could you briefly
describe your workflow or point me to references/documentation?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie user: Feedback on custom package definition
2023-02-28 22:06 Newbie user: Feedback on custom package definition Rodrigo Morales
@ 2023-03-01 1:12 ` 宋文武
2023-03-02 15:10 ` Gary Johnson
1 sibling, 0 replies; 6+ messages in thread
From: 宋文武 @ 2023-03-01 1:12 UTC (permalink / raw)
To: Rodrigo Morales; +Cc: help-guix
Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:
> [...]
> | #:builder
> | #~(begin
> | (use-modules (guix build utils))
> | (chdir (assoc-ref %build-inputs "source"))
> | (install-file "org-recoll.el"
> | (string-append
> | #$output
> | "/.config/emacs/libs")))))
> | (synopsis "My synopsis")
> | (description "My description")
> | (home-page "https://example.org/")
> | (license gpl3+)))
> [...]
>
> 3 The questions
> ===============
>
> + What changes would you do to improve the definition of the package
> that I wrote?
I would update the synopsis, description, and switch from
trivial-build-system to emacs-build-system, and send a patch to
guix-patches.
> + Do you manage your Emacs packages with GUIX? Could you briefly
> describe your workflow or point me to references/documentation?
Yes, I just:
1. install emacs packages (emacs, emacs-use-package, emacs-magit, etc.)
by 'guix package -i' or 'guix package -m'.
2. setup them usually in ~/.emacs.init with '(use-package ...)'.
Packages installed by guix are available to emacs like package-install
thanks to 'guix-emacs-autoload-apckages'.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie user: Feedback on custom package definition
2023-02-28 22:06 Newbie user: Feedback on custom package definition Rodrigo Morales
2023-03-01 1:12 ` 宋文武
@ 2023-03-02 15:10 ` Gary Johnson
2023-03-02 18:54 ` Vagrant Cascadian
1 sibling, 1 reply; 6+ messages in thread
From: Gary Johnson @ 2023-03-02 15:10 UTC (permalink / raw)
To: Rodrigo Morales; +Cc: help-guix
Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:
> 8<-----------------------------------
> 8< ...Text elided...
> 8<-----------------------------------
>
>
> 3 The questions
> ===============
>
> + What changes would you do to improve the definition of the package
> that I wrote?
Whenever possible, you should not be using the `trivial-build-system`.
Guix comes with a wealth of built-in build systems that will take care
of building and installing packages written in many different languages.
For Emacs Lisp packages, you should use the `emacs-build-system`. Here
is an example:
```
(define-public emacs-vcard
(package
(name "emacs-vcard")
(version "0.2.1")
(source
(origin
(method url-fetch)
(uri (string-append
"https://elpa.gnu.org/packages/vcard-"
version
".tar"))
(sha256
(base32 "0nfrh1mz2h7h259kf7sj13z30kmjywfvs83ax5qjkfwxhqm03abf"))))
(build-system emacs-build-system)
(home-page "https://elpa.gnu.org/packages/vcard.html")
(synopsis "Package for handling vCard files")
(description
"This file contains `vcard-mode', for viewing vCard files. Other files in this
package contain functions for parsing and writing vCard data.")
(license gpl3+)))
```
This will download and validate the source, build the package, install
it under /gnu/store, and symlink it into the profile that you installed
it into. It will take care of adding these directories to these
environment variables, which ensure that Emacs can require them later:
- EMACSLOADPATH
- EMACSNATIVELOADPATH
> + Do you manage your Emacs packages with GUIX? Could you briefly
> describe your workflow or point me to references/documentation?
I do manage all of my Emacs packages with Guix. I list `emacs` and all
of its packages in a manifest file (emacs.scm). It looks like this with
my custom packages elided:
```
(use-modules ((gnu packages) #:select (specifications->manifest)))
(specifications->manifest
(list "emacs"
"emacs-adoc-mode"
"emacs-alsamixer-el"
"emacs-async"
"emacs-calibredb"
"emacs-cider"
"emacs-clojure-mode"
"emacs-company"
"emacs-crdt"
"emacs-csv-mode"
"emacs-elpher"
"emacs-emms"
"emacs-eww-lnum"
"emacs-exwm"
"emacs-flycheck"
"emacs-flymake-kondor"
"emacs-flyspell-correct"
"emacs-forge"
"emacs-geiser"
"emacs-geiser-guile"
"emacs-gnuplot"
"emacs-google-translate"
"emacs-helm"
"emacs-helm-ag"
"emacs-helm-descbinds"
"emacs-helm-swoop"
"emacs-htmlize"
"emacs-magit"
"emacs-markdown-mode"
"emacs-nov-el"
"emacs-ob-async"
"emacs-org"
"emacs-org-pomodoro"
"emacs-ox-gfm"
"emacs-paredit"
"emacs-pdf-tools"
"emacs-pinentry"
"emacs-rjsx-mode"
"emacs-shroud"
"emacs-telephone-line"
"emacs-treemacs"
"emacs-vterm"
"emacs-web-mode"
"emacs-which-key"
"mu"))
```
I actually split up all the user packages on my system into manifests
and isntall each one into its own profile, which I then activate on
startup. However, that's not really necessary for this example. You can
install the manifest packages above into your user profile with this
command:
```
guix package -m emacs.scm
```
If you want to include packages that you wrote yourself, you can either
add them to your GUIX_PACKAGE_PATH environment variable or you can
create your own Guix channel, add it to your ~/.config/guix/channels.scm
file, and run `guix pull`.
To get help in writing new Guix packages for Emacs, try out the `guix
import elpa` command like so:
```
guix import elpa --archive=melpa gemini-mode
```
Alright. That's it for now. Good luck and happy hacking!
~Gary
--
Protect yourself from surveillance: https://emailselfdefense.fsf.org
=======================================================================
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
Why is HTML email a security nightmare? See https://useplaintext.email/
Please avoid sending me MS-Office attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie user: Feedback on custom package definition
2023-03-02 15:10 ` Gary Johnson
@ 2023-03-02 18:54 ` Vagrant Cascadian
2023-03-02 19:57 ` (
0 siblings, 1 reply; 6+ messages in thread
From: Vagrant Cascadian @ 2023-03-02 18:54 UTC (permalink / raw)
To: Gary Johnson, Rodrigo Morales; +Cc: help-guix
[-- Attachment #1: Type: text/plain, Size: 792 bytes --]
On 2023-03-02, Gary Johnson wrote:
> Rodrigo Morales <moralesrodrigo1100@gmail.com> writes:
>> 3 The questions
>> ===============
>>
>> + What changes would you do to improve the definition of the package
>> that I wrote?
>
> Whenever possible, you should not be using the `trivial-build-system`.
I often wonder if the name "trivial-build-system" should not be
something more like:
diy-get-your-hands-messy-with-a-lot-of-effort-build-system
I think the word "trivial" implies to people that it should be easy to
use with trivial packaging tasks, when in fact, the build system does so
little that you actually have to do a lot of work to get it to generate
a proper package... I certainly fell down that trap when I first started
working on some packages...
live well,
vagrant
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie user: Feedback on custom package definition
2023-03-02 18:54 ` Vagrant Cascadian
@ 2023-03-02 19:57 ` (
2023-03-07 13:41 ` Simon Tournier
0 siblings, 1 reply; 6+ messages in thread
From: ( @ 2023-03-02 19:57 UTC (permalink / raw)
To: Vagrant Cascadian, Gary Johnson, Rodrigo Morales; +Cc: help-guix
[-- Attachment #1: Type: text/plain, Size: 264 bytes --]
On Thu Mar 2, 2023 at 6:54 PM GMT, Vagrant Cascadian wrote:
> I often wonder if the name "trivial-build-system" should not be
> something more like:
>
> diy-get-your-hands-messy-with-a-lot-of-effort-build-system
Maybe PRIMITIVE-BUILD-SYSTEM?
-- (
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Newbie user: Feedback on custom package definition
2023-03-02 19:57 ` (
@ 2023-03-07 13:41 ` Simon Tournier
0 siblings, 0 replies; 6+ messages in thread
From: Simon Tournier @ 2023-03-07 13:41 UTC (permalink / raw)
To: (, Vagrant Cascadian, Gary Johnson, Rodrigo Morales; +Cc: help-guix
Hi,
On Thu, 02 Mar 2023 at 19:57, "(" <paren@disroot.org> wrote:
> On Thu Mar 2, 2023 at 6:54 PM GMT, Vagrant Cascadian wrote:
>> I often wonder if the name "trivial-build-system" should not be
>> something more like:
>>
>> diy-get-your-hands-messy-with-a-lot-of-effort-build-system
>
> Maybe PRIMITIVE-BUILD-SYSTEM?
Well, I am not convinced that we should change the name. It is there
since some many years. :-)
However, we could improve the manual. For instance, it reads [1] «A
notable exception is the “bare-bones” trivial-build-system (see Build
Systems).»
Then under “Build System“ section [2], this “bare-bones” could be more
explicit. For example, extend a bit its documentation [3].
Well, it will mitigate a bit the common “trap” about the most
non trivial build system. :-)
1: <https://guix.gnu.org/manual/devel/en/guix.html#Build-Phases>
2: <https://guix.gnu.org/manual/devel/en/guix.html#Build-Systems>
3: <https://guix.gnu.org/manual/devel/en/guix.html#index-trivial_002dbuild_002dsystem>
Cheers,
simon
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-07 13:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28 22:06 Newbie user: Feedback on custom package definition Rodrigo Morales
2023-03-01 1:12 ` 宋文武
2023-03-02 15:10 ` Gary Johnson
2023-03-02 18:54 ` Vagrant Cascadian
2023-03-02 19:57 ` (
2023-03-07 13:41 ` Simon Tournier
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).