From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8OgeKzxplWCmOgAAgWs5BA (envelope-from ) for ; Fri, 07 May 2021 18:22:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SGLUJjxplWCfSwAA1q6Kng (envelope-from ) for ; Fri, 07 May 2021 16:22:20 +0000 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 12C9F18F2C for ; Fri, 7 May 2021 18:22:20 +0200 (CEST) Received: from localhost ([::1]:58660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lf3F3-0002dx-KN for larch@yhetil.org; Fri, 07 May 2021 12:22:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf3Es-0002dp-FT for help-guix@gnu.org; Fri, 07 May 2021 12:22:06 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lf3Eq-0003da-Cc for help-guix@gnu.org; Fri, 07 May 2021 12:22:06 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1620404518; cv=none; d=zohomail.com; s=zohoarc; b=SDHZv5AtmaFf+SIdbNfDexWYT0ahp2ZhPCyk5odSBIMb6wC3yfc4TbHh9Tiueui5cRdLq8BhkrV+lJIlSdAxk/YOp2CQdg4W4RJqSMg5Rx/RndGD2GoQ6jeDVdoZJ2kedSswrUB0VKj3foPTPDcbTa/57LT61nkOBef2ln/baco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620404518; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jj3qiwzQfsA1n43V/PKfQYjozRcQ8tCIhEQJikvEZVk=; b=RQ5vl8+9rv3ABH3BvNNYOaB95p4jt2y6atEqb6Rr28PFh2vtvE4orxBbd/eZ3XLnPevQJAnkUI7wxcOoAvjlc0CZ7v+4hV7gNlrjUpIuDS3DW8psshzq1Vz4GOMgJ45gs7nRwJmMYo8ZNwjS75E53ySgoIWuq2SKlEzLePVquJk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=rdklein.fr; spf=pass smtp.mailfrom=edou@rdklein.fr; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1620404518; s=zoho; d=rdklein.fr; i=edou@rdklein.fr; h=References:From:To:Cc:Subject:Message-ID:In-reply-to:Date:MIME-Version:Content-Type; bh=jj3qiwzQfsA1n43V/PKfQYjozRcQ8tCIhEQJikvEZVk=; b=fk7ayJnSPI1SW8Twvh9/G8CrdpLOKxGhHhW4gzT8CIJzSjDWXP681otdrxszXzUP JGGiODR23T1o0lQqQGRI8KRHOQtKj95F2Uv1O0F1r5VPyGwEOox7/N4jccuadzRdyQn TK9blQTGrDcPuEOoGSY63lPNRB50YzbCmI+VVYb8= Received: from Rasoir (lfbn-idf3-1-808-29.w90-3.abo.wanadoo.fr [90.3.133.29]) by mx.zohomail.com with SMTPS id 162040451649592.03785217365225; Fri, 7 May 2021 09:21:56 -0700 (PDT) References: <87eeelglsm.fsf@rdklein.fr> <87tunhavsy.fsf@cbaines.net> User-agent: mu4e 1.4.15; emacs 27.1 From: Edouard Klein To: Christopher Baines Subject: Re: How to lower a record to the build code ? Message-ID: <8735uyjzug.fsf@rdklein.fr> In-reply-to: <87tunhavsy.fsf@cbaines.net> Date: Fri, 07 May 2021 18:21:29 +0200 MIME-Version: 1.0 Content-Type: text/plain X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.11; envelope-from=edou@rdklein.fr; helo=sender4-op-o11.zoho.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: help-guix@gnu.org Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620404540; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=jj3qiwzQfsA1n43V/PKfQYjozRcQ8tCIhEQJikvEZVk=; b=utuUctAvOm95oN4J2CGyOyMXxfbfqmjMADKjEeoPf5NckPeaIWaKmyv9Hlk6pYfEGFVXaF o7/lNTNbZ1lqHUkjDOQgCLQrsis+IpjdsRm0XjtV4CX5lfgG62qCrtv3hCelvSbLwCaWLH TBRlUlF8hIDKfuSFNlcE+XWphMcwh4Cnpxat0F4Lfkml30mk5BNs8Jh9tZIPKnyVqIkTrs xhNpYH2rWklBm40rsPRsLJcku1IHHpG2319tRPQXAZ7wnVFiS+9oeLbbsd3lsaoG7FPfpN LBVx+zyr7DQB586xv5Jfs9n8PcSgiaH+/XQXO7c5ozexDaCElfAipGuNpcHg5w== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1620404540; a=rsa-sha256; cv=pass; b=R/Cc3xVEL3dEDgeLcTZBGQduqIQl4WC9jVJN6uKS/n0XdVCcaxk6+DZlSRufwTC+x+GAHP iKgUVMS0x+6nZteiIMSeGhov64YhMjetbfQQ/a0XwhSFplj4qVGKecYA1+ELSEbN2LVb35 C/jfuFOwZ7Y3yM7UYbaJIGabxdNAtyhBOqpFq4PVH30MqI4qZ0UOXoIJN1sQm71jaNbPmS FP6LbQUnt96ZrsX3fdv1vzXLTbLWBafunlP8VAJVLMJOqCZLmIMD4B85pTol1arO+n+iQ+ hSCF5spS6JoFmDU1h3Kx2jVte9811ffe5iGYddj76CZgQ4K3WM3n+i09d3a82w== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=rdklein.fr header.s=zoho header.b=fk7ayJnS; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Spam-Score: -0.95 Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=rdklein.fr header.s=zoho header.b=fk7ayJnS; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Queue-Id: 12C9F18F2C X-Spam-Score: -0.95 X-Migadu-Scanner: scn0.migadu.com X-TUID: HBZQsp/fnpZq Dear Christopher, I can't thank you enough, your idea of "ungexp[ing] the record access bits" is what got me out of the tarpit. You can see the resulting code here, which will hopefully clear the misunderstandings generated by my oversimplification of the minimal nonworking example: https://issues.guix.gnu.org/issue/48277 Thanks again ! Cheers, Edouard. Christopher Baines writes: > edk@beaver-labs.com writes: > >> I've been stuck for a few days on the following: >> Let's say I have a record type: >> >> (define-record-type* my-record make-my-record >> my-record? >> this-record >> (first-field my-record-first-field) >> (second-field my-record-second-field)) >> >> And a function that uses such a record, but needs to run on the build >> side, because it also needs the store path of a package (I can't edit >> this function): >> >> (define (function-of-a-record-and-a-build-time-path rec path) >> "Concatenate the path, first, and second field" >> (string-append path " " (my-record-first-field rec) " " (car >> (my-record-second-field rec)) " " (cdr (my-record-second-field rec)))) >> >> How can I use this record in the build side. For example, I'm unable to >> build the following G-exp: >> (define a-record (my-record >> (first-field "first") >> (second-field '("second" . "third")))) >> >> >> #~(with-output-to-file (string-append #$output "/file.txt") >> (lambda _ >> (display (function-of-a-record-and-a-build-time-path #$a-record >> #$bash))))) > > Could you ungexp the record access bits? So something like: > > (string-append #$path " " #$(my-record-first-field rec) " " #$(car > (my-record-second-field rec)) " " #$(cdr (my-record-second-field > rec))) > > Obviously, then the handling of rec would just be on the build side. > > I'm not quite sure quite what your code looks like, in the example you > give, you've got a number of problems. > > Ignoring the #$a-record, you'll need to (mkdir #$output) before trying > to write to a file within that directory. > > Secondly, function-of-a-record-and-a-build-time-path isn't defined on > the build side. > > If you want to define function-of-a-record-and-a-build-time-path on the > host side, then you could have it return a gexp, something like: > > (define (function-of-a-record-and-a-build-time-path rec path) > "Concatenate the path, first, and second field" > #~(string-append #$path " " #$(my-record-first-field rec) " " #$(car (my-record-second-field rec)) " " #$(cdr (my-record-second-field rec)))) > > (build-gexp > #~(begin > (mkdir #$output) > (with-output-to-file (string-append #$output "/file.txt") > (lambda _ > (display #$(function-of-a-record-and-a-build-time-path a-record bash)))))) > > With these changes, the example you give works for me.