From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 8GvoM73yVmdLmgAAqHPOHw:P1 (envelope-from ) for ; Mon, 09 Dec 2024 13:38:05 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 8GvoM73yVmdLmgAAqHPOHw (envelope-from ) for ; Mon, 09 Dec 2024 14:38:05 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=ocAbRylY; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1733751485; a=rsa-sha256; cv=none; b=X/5YGQyX843StL7zLX21uaV+A2Jf4W+kA4FLoc6bosGQyWBshZE/bDJEVJmtEaC4biWezH ETKAudJuh/D3XN2dGN61wIeaGRUlNLJ6xgHGFe4TEzLAdsFLMPQEOkQeWGDLd9VlLRnmSn bxnjgufAblDuP61kzrJZo4qUoOYT/B370knFwxbKhfZs/O07hW5bfDjMKw7YU//vJNf4XY aosuT7Krc+Sd2KPdC1Hr8j4/GC+zMucG/lYZdtl8EXy5kjIxdmHfqe49SImKwiEml1wiyf vTfEmfSTJEoW3SjysF3veqBco0iKQ9N326Tvbt1z6ucohnjPoCVdtp/jZHyI3w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=ocAbRylY; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1733751485; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=WuNqEzHr2KfuQI1UUn93V9V5Ipdd3X1tHOo9UnwSmXE=; b=kGKN4nbRB8pfEBNMpVdIl/15GnMylcf3scxelsiAhopS66ykPWoeUUdONYr2gu/aCassvV tIcrjnHFmW9CgnKb4DJ82C8bhKyAQ9KXtimFfEAxz5Isof+3uXc0wVliA+ldaio7DFYyXu aAWtr6SacCpAbN7HBBT3IB/qQTTO0HQ3yN9F18Wih1SYzXeQGrnSPJQiIEUq4lTAIOc8Zx x6bWm7MNQGBuI9gx7kQWFhKn3d2L7sC88zO6LRUYuwfKQPwBONlW8FgePbbCFUoGkpjIGn DON3k7yUSbutEkMKIQ4KVslNnWyJK9F6t0UaWKMhNw9cG3Aum0ITQLdMsv7PKw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7BEE0636B for ; Mon, 09 Dec 2024 14:38:05 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKdx4-0006GA-RJ; Mon, 09 Dec 2024 08:37:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKdx1-0006Fc-Ab for help-guix@gnu.org; Mon, 09 Dec 2024 08:37:27 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKdwz-0007GD-3g for help-guix@gnu.org; Mon, 09 Dec 2024 08:37:27 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id F2CCC240101 for ; Mon, 9 Dec 2024 14:37:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1733751440; bh=wfmKeu9/ZsLqZOucqswJkCs3Rtd2BYTWWIRfRUmVtF0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=ocAbRylYGTvBjRqqd/tN/frXmks6+Z/g9keoAXr3KNcMAnx6kDlv9ezZ9WTKSktol y7f4ybPu9OlNRGdbp2oIVmJtGmhTJyYjqccQogFoNYXXymaKlvhQyquLuDyR0j5mOn 9xXRT88zetngYs0ifXnZkp35g6/NNUTYMkmvjqTvl4s8IyRAdP33yKuM5lN5R4bHWU s0FjbrPw91AH98jInsXi28P1l70BVYj/FyKnCBBa5Pdg7fkBEyhZKyYwByFpqwyRiS xcQNEalmznaflzJmPdAySEeL8h/11QN+bp5q2DkBytr4lWdG04unf67fQcEknad7HS 4Gd5tkh+WoWUA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Y6NFq5QyHz6tvw; Mon, 9 Dec 2024 14:37:19 +0100 (CET) From: Yulran To: Julien Lepiller Cc: help-guix@gnu.org Subject: Re: Nested gexps in mcron job definitions In-Reply-To: <0B208CFA-731C-47E7-AE64-F4FAA12BFD8F@lepiller.eu> (Julien Lepiller's message of "Mon, 09 Dec 2024 14:08:01 +0100") References: <87o71lc9sy.fsf@posteo.net> <0B208CFA-731C-47E7-AE64-F4FAA12BFD8F@lepiller.eu> Date: Mon, 09 Dec 2024 13:37:18 +0000 Message-ID: <87ikrtc701.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.66; envelope-from=yulran@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 7BEE0636B X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -9.38 X-Spam-Score: -9.38 X-TUID: ry4UXLmPL570 Hi Julien, thank you! That does work. So if I understand correctly, #$ doesn't only escape #~ but also unquotes q= uoted lists. That's good to know! It's possible a good fraction of my recur= ring troubles with gexps came from not realizing that. On Mon, Dec 09 2024, Julien Lepiller wrote: > Hi Yulran, > > I think this is related to how gexps are expanded. In your first gexp, yo= u use #$accounts, which expands to ("account1" "account2"), and it's interp= reted as a procedure call. > > Untested, but '#$accounts should work. > > It might be easier to work with a single gexp, like so: > > #~(job '(next-second (range 1 61 10)) > (lambda () > (let ((accounts =E2=80=A6)) > =E2=80=A6 > (system =E2=80=A6)))) > > Le 9 d=C3=A9cembre 2024 13:36:45 GMT+01:00, Yulran a = =C3=A9crit=C2=A0: >>Hi guix, >> >>I'm having trouble with nesting g-expressions when defining a mcron job. = I want the job to run the same "mastodon-archive" commands for several acco= unts, so I define a list of accounts and use 'map' to build the complete co= mmand. This works well when there are only strings involved, but I can't ma= ke it work with gexps. >> >>Here's a simplified example with only strings: >> >>--8<---------------cut here---------------start------------->8--- >>(define succeeding-job >> (let* ((accounts '("account1" "account2")) >> (cmd (apply string-append >> (map >> (lambda (acct) >> (string-append >> "mastodon-archive archive " acct "; ")) >> accounts)))) >> #~(job '(next-second (range 1 61 10)) >> (lambda () >> (system (string-append "echo '" #$cmd "'"))) >> "mastodon-archive"))) >>--8<---------------cut here---------------end--------------->8--- >> >>The job succeeds and the mcron log prints as expected "mastodon-archive a= rchive account1; mastodon-archive archive account2;". Now to use the full p= ath to the mastodon-archive binary, cmd must be a gexp: >> >>--8<---------------cut here---------------start------------->8--- >>(define failing-job >> (let* ((accounts '("account1" "account2")) >> (cmd #~(apply string-append >> (map >> (lambda (acct) >> (string-append >> #$mastodon-archive "/bin/mastodon-archive arch= ive " acct "; ")) >> #$accounts)))) >> #~(job '(next-second (range 1 61 10)) >> (lambda () >> (system (string-append "echo '" #$cmd "'"))) >> "mastodon-archive"))) >>--8<---------------cut here---------------end--------------->8--- >> >>The home configuration builds fine, but the mcron job fails with the erro= r: (wrong-type-arg #f Wrong type to apply: ~S (account1) (account1)) >> >>I played around with gexp-ing the string-append in the lambda, ungexp-ing= acct, and trying every other combination of gexp/ungexp I could think of, = but I could only make it worse. >> >>Any idea what I'm doing wrong? >>