help-guix
[Top][All Lists]
Advanced

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

defining package variants automatically


From: Ricardo Wurmus
Subject: defining package variants automatically
Date: Sun, 08 Sep 2019 00:50:21 +0200
User-agent: mu4e 1.2.0; emacs 26.2

Hi Guix,

I played a little with defining package variants automatically, but I
can’t get this to work.  The idea of this module is to define a variant
for every package using the emacs-build-system, such that it uses a
different Emacs variant during the build.

All of these packages should be exported as variables of the (gnu
packages emacs-custom) module.

Unfortunately, none of the dynamically defined variables are visible, so
none of the packages are accessible by Guix.  Is there something
obviously wrong here?

--8<---------------cut here---------------start------------->8---
(define-module (gnu packages emacs-custom)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages emacs)
  #:use-module (gnu packages emacs-xyz)
  #:use-module (guix build-system emacs))

(define my-custom-emacs emacs-no-x) ; just a test

(define package-with-my-emacs
  (package-mapping
   (lambda (pkg)
     (package
       (inherit pkg)
       (name (string-append (package-name pkg) "-rekado"))
       (arguments
        (substitute-keyword-arguments (package-arguments pkg)
          ((#:emacs _ '())
           my-custom-emacs)))))
   (lambda (pkg)
     (eq? emacs-build-system (package-build-system pkg)))))

(fold-packages (lambda (pkg result)
                 (let ((variable-name
                        (string->symbol (string-append (package-name pkg) 
"-rekado"))))
                   (module-define!
                    (resolve-module '(gnu packages emacs-custom))
                    variable-name
                    (package-with-my-emacs pkg))
                   (export variable-name))
                 result)
               '()
               #:select?
               (lambda (pkg)
                 (eq? emacs-build-system (package-build-system pkg))))
--8<---------------cut here---------------end--------------->8---

--
Ricardo




reply via email to

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