[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: WSDD Service Module
From: |
Ludovic Courtès |
Subject: |
Re: WSDD Service Module |
Date: |
Tue, 25 Jan 2022 14:56:53 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
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’.