From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: Some macros to make package definitions prettier
Date: Thu, 26 Feb 2015 12:07:47 +0100 [thread overview]
Message-ID: <877fv553ss.fsf@taylan.uni.cx> (raw)
In-Reply-To: <87bnkhzhxd.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 26 Feb 2015 00:32:14 +0100")
[-- Attachment #1: Type: text/plain, Size: 397 bytes --]
ludo@gnu.org (Ludovic Courtès) writes:
> taylanbayirli@gmail.com (Taylan Ulrich "Bayırlı/Kammer") skribis:
>
>> (modify-phases '((foo . 0) (bar . 1) (baz . 2))
>> (delete foo)
>> (replace bar 'x)
>> (add-before baz pre-baz 'y)) ;=> ((bar . x) (pre-baz . y) (baz . 2))
>
> I like it! Let’s put it in (guix utils)?
Shouldn't it go to (guix build utils)? Here's a patch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2117 bytes --]
From 320a974e9b04959544bb93c67766957541ec02ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
<taylanbayirli@gmail.com>
Date: Thu, 26 Feb 2015 11:51:11 +0100
Subject: [PATCH] utils: Add 'modify-phases'.
* guix/build/utils.scm (modify-phases): New macro.
---
guix/build/utils.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 4407f9a..c35966f 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -54,6 +54,7 @@
alist-cons-before
alist-cons-after
alist-replace
+ modify-phases
with-atomic-file-replacement
substitute
substitute*
@@ -423,6 +424,33 @@ An error is raised when no such pair exists."
((_ after ...)
(append before (alist-cons key value after))))))
+(define-syntax-rule (modify-phases phases mod-spec ...)
+ "Modify PHASES sequentially as per each MOD-SPEC, which may have one of the
+following forms:
+
+ (delete <old-phase-name>)
+ (replace <old-phase-name> <new-phase>)
+ (add-before <old-phase-name> <new-phase-name> <new-phase>)
+ (add-after <old-phase-name> <new-phase-name> <new-phase>)
+
+Where every <*-phase-name> is an automatically quoted symbol, and <new-phase>
+an expression evaluating to a procedure."
+ (let* ((phases* phases)
+ (phases* (%modify-phases phases* mod-spec))
+ ...)
+ phases*))
+
+(define-syntax %modify-phases
+ (syntax-rules (delete replace add-before add-after)
+ ((_ phases (delete old-phase-name))
+ (alist-delete 'old-phase-name phases))
+ ((_ phases (replace old-phase-name new-phase))
+ (alist-replace 'old-phase-name new-phase phases))
+ ((_ phases (add-before old-phase-name new-phase-name new-phase))
+ (alist-cons-before 'old-phase-name 'new-phase-name new-phase phases))
+ ((_ phases (add-after old-phase-name new-phase-name new-phase))
+ (alist-cons-after 'old-phase-name 'new-phase-name new-phase phases))))
+
\f
;;;
;;; Text substitution (aka. sed).
--
2.2.1
[-- Attachment #3: Type: text/plain, Size: 97 bytes --]
On the other topic, I'm afraid I know yet too little about gexprs and
Guix internals...
Taylan
next prev parent reply other threads:[~2015-02-26 11:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-25 16:42 Some macros to make package definitions prettier Taylan Ulrich Bayırlı/Kammer
2015-02-25 17:04 ` Thompson, David
2015-02-25 17:06 ` Thompson, David
2015-02-25 19:27 ` Taylan Ulrich Bayırlı/Kammer
2015-02-25 20:54 ` Taylan Ulrich Bayırlı/Kammer
2015-02-25 18:12 ` Andreas Enge
2015-02-25 19:46 ` Taylan Ulrich Bayırlı/Kammer
2015-02-25 20:24 ` Thompson, David
2015-02-25 23:32 ` Ludovic Courtès
2015-02-26 11:07 ` Taylan Ulrich Bayırlı/Kammer [this message]
2015-02-26 21:39 ` Ludovic Courtès
2015-03-03 16:49 ` Taylan Ulrich Bayırlı/Kammer
2015-03-03 20:44 ` Ludovic Courtès
2015-03-03 22:47 ` Taylan Ulrich Bayırlı/Kammer
2015-03-04 9:52 ` Ludovic Courtès
2015-02-26 21:41 ` Ludovic Courtès
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=877fv553ss.fsf@taylan.uni.cx \
--to=taylanbayirli@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@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.