all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Simon Streit <simon@netpanic.org>
Cc: Guix Devel <guix-devel@gnu.org>
Subject: Re: WSDD Service Module
Date: Tue, 25 Jan 2022 14:56:53 +0100	[thread overview]
Message-ID: <871r0vncka.fsf@gnu.org> (raw)
In-Reply-To: <ygu8rv4ouls.fsf@netpanic.org> (Simon Streit's message of "Tue, 25 Jan 2022 13:41:51 +0100")

Hi,

(+Cc: guix-devel.)

Simon Streit <simon@netpanic.org> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>> My understanding is that you intend the ‘interface’ field to be either
>> #f or a string, is that right?
>
> I think it rather be a list of strings,

Then I recommend calling it ‘interfaces’ (plural).

>> When you write:
>>
>>   (interface)
>>
>> that means: “call the procedure bound to ‘interface’, passing it zero
>> arguments”.  However, if ‘interface’ is a string, you cannot call it, so
>> you get a wrong-type-to-apply error.
>>
>> Likewise, ‘for-each’ expects its second argument to be a list.  But
>> here, ‘interface’ is supposedly a string, not a list, so if you do:
>>
>>   (for-each (lambda …) interface)
>>
>> you’ll get a wrong-type-argument error.
>
> So I changed it, that interface is usually an empty list now, and with
> for-each I'd like to have it expanded.  Good thing is, I've gotten at
> least a step further, but only after hard coding the list as an argument
> in the for-each expression.  So it should work?  It still doesn't.  And
> I still don't understand how it is somehow not passed as a list
> properly.  
>
> One thing I noticed, after hard coding the argument, the procedure is
> not properly expanded in the constructor.  How come?  This is the output
> in the service file:
>
> (make-forkexec-constructor
>  (list "/gnu/store/6jpn21wnnyz59ii634hfbk34yy48nxrq-wsdd-0.6.4/bin/wsdd" "--hoplimit" "1" for-each
>        (lambda
>            (arg)
>          (format #t "--interface ~s "
>                  (arg)))
>        (interface)
>        "--workgroup" "WORKGROUP")
>  #:user "wsdd" #:group "wsdd" #:log-file "/var/log/wsdd.log")

This reads “(interface)”, meaning that (1) ‘interface’ must be a
procedure, since you’re calling it, and (2) ‘interface’ must be bound
(the variable must be defined there).

However, ‘interface’ is unbound here.  You probably meant to write,
within your gexp:

  #~(make-forkexec-constructor
      … #$@(map (lambda …) interfaces)
      …)

which would expand to:

  (make-forkexec-constructor
    … "--interface=eth0" "--interface=eth1"
    …)

The #$@ bit (‘ungexp-splicing’) means that the (map …) bit executes
beforehand and that its results is staged in that generated shepherd
file.

HTH,
Ludo’.


  parent reply	other threads:[~2022-01-25 15:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-19  9:29 WSDD Service Module Simon Streit
2022-01-24 15:46 ` Ludovic Courtès
2022-01-25 12:56   ` Simon Streit
     [not found]   ` <ygu8rv4ouls.fsf@netpanic.org>
2022-01-25 13:56     ` Ludovic Courtès [this message]
2022-01-25 19:10       ` Simon Streit
  -- strict thread matches above, loose matches on Subject: below --
2022-01-21 11:51 Simon Streit

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=871r0vncka.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=simon@netpanic.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.