unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: nee <nee@cock.li>
Cc: 28960@debbugs.gnu.org
Subject: [bug#28960] [PATCH] services: Add murmur.
Date: Tue, 24 Oct 2017 14:34:23 -0700	[thread overview]
Message-ID: <87wp3kmdr4.fsf@gnu.org> (raw)
In-Reply-To: <f1d9f3c9-dd8e-b1ac-f19a-15e683de6194@cock.li> (nee@cock.li's message of "Tue, 24 Oct 2017 19:19:53 +0200")

[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]

Hi nee,

nee <nee@cock.li> skribis:

>>> +(define murmur-shepherd-service
>>> …
>> Use the accessors instead.
>>
> Right, that grew way too big. I removed most of the match blocks.
> I like having the short names when it comes to stitching together the
> actual config though, so I kept that one.
> If that's still a no-go I'll make another update with accessors.
>
> If the main problem here is the positional binding, is there a function
> to match record fields by name that I could use instead?

Unfortunately no.

> It doesn't seem like it would be too complicated to write a macro for
> this with the record-accessor procedure from srfi-9.

Indeed.  I figured something like this works:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (define-syntax match-record
		       (syntax-rules ()
			 ((_ record type (field fields ...) body ...)
			  (if (eq? (struct-vtable record) type)
			      (let ((field ((record-accessor type 'field) record)))
				(match-record record type (fields ...) body ...))
			      (throw 'wrong-type-arg record)))
			 ((_ record type () body ...)
			  (begin body ...))))
scheme@(guile-user)> (match-record coreutils (@@ (guix packages) <package>) (home-page) home-page)
$6 = "https://www.gnu.org/software/coreutils/"
scheme@(guile-user)> (match-record coreutils (@@ (guix packages) <package>) (home-page synopsis) (list synopsis home-page))
$7 = ("Core GNU utilities (file, text, shell)" "https://www.gnu.org/software/coreutils/")
--8<---------------cut here---------------end--------------->8---

We could use that for now.

Eventually though, we should have something better in (guix records)
that (1) computes indices and report wrong-field-name errors at
expansion time, and (2) accounts for thunked/delayed fields.

WDYT?

If the above macro is good enough, we can add it to (guix records) with
a TODO comment.  That would already be better than the other options.

> I also noticed a missing equal sign after rememberchannel in the
> defaultconfig and added that.

I noticed a couple of obvious mistakes:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1185 bytes --]

diff --git a/gnu/services/telephony.scm b/gnu/services/telephony.scm
index 0c30b409f..a305a1be8 100644
--- a/gnu/services/telephony.scm
+++ b/gnu/services/telephony.scm
@@ -240,7 +240,7 @@ Or set public-registration to #f")))))))))
 (define (murmur-activation config)
   #~(begin
       (use-modules (guix build utils))
-      (let ((log-dir (dirname #$(murmur-configuration-log-file config)))
+      (let* ((log-dir (dirname #$(murmur-configuration-log-file config)))
              (pid-dir (dirname #$(murmur-configuration-pid-file config)))
              (db-dir (dirname #$(murmur-configuration-database-file config)))
              (user (getpwnam #$(murmur-configuration-user config)))
@@ -283,7 +283,7 @@ Or set public-registration to #f")))))))))
          (documentation "Run the murmur mumble-server.")
          (requirement '(networking))
          (start #~(make-forkexec-constructor
-                   '(#$(file-append (murmur-configuration-package)
+                   '(#$(file-append (murmur-configuration-package config)
                                     "/bin/murmurd")
                      "-ini"
                      #$(or (murmur-configuration-file config)

[-- Attachment #3: Type: text/plain, Size: 318 bytes --]


This makes me think that it would be good to have a unit test.  Would
you like to try writing one now (see the examples in gnu/tests/*.scm),
or do you prefer to leave it for later?

In the latter case, please test the system to make sure it actually
works (that can be done in a VM.)

Thank you!

Ludo’.

  reply	other threads:[~2017-10-24 21:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-23 21:34 [bug#28960] [PATCH] services: Add murmur nee
2017-10-24  4:32 ` ng0
2017-10-24  5:04 ` Ludovic Courtès
2017-10-24 17:19   ` nee
2017-10-24 21:34     ` Ludovic Courtès [this message]
2017-10-30 22:38       ` nee
2017-10-31  0:02         ` Ludovic Courtès
2017-11-05 10:42         ` bug#28960: " 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wp3kmdr4.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=28960@debbugs.gnu.org \
    --cc=nee@cock.li \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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).