From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id IKC6OcTTkmAj5AAAgWs5BA (envelope-from ) for ; Wed, 05 May 2021 19:20:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id BNtsNcTTkmAZLwAA1q6Kng (envelope-from ) for ; Wed, 05 May 2021 17:20:04 +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 2C6EC12D78 for ; Wed, 5 May 2021 19:20:04 +0200 (CEST) Received: from localhost ([::1]:49158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leLBq-0007Rb-Os for larch@yhetil.org; Wed, 05 May 2021 13:20:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKu8-0006Ld-3w for help-guix@gnu.org; Wed, 05 May 2021 13:01:49 -0400 Received: from sender4-op-o11.zoho.com ([136.143.188.11]:17108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKtu-0002UK-7k for help-guix@gnu.org; Wed, 05 May 2021 13:01:43 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1620234066; cv=none; d=zohomail.com; s=zohoarc; b=Zr69p4JY62ugtVDdkAao8glEtk05WLVG1l5oKCbn4i5tPhnM6kLzVduxdZaeKQgCqBu3H1SAQx/taPjBe0RZvr1F/j5EDToOBFPuLJjy3wgc1hCiTFhs9WWYMqT8NF+VbG9EcLvwNVGX/Ae+cOzUEaiG4/PVc4nbF3c/IJGK/K8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620234066; h=Content-Type:Date:From:MIME-Version:Message-ID:Subject:To; bh=tPyAtOK3FEYo8hGWIuw+K15c8yIuyhwJAbF9wgaZrJw=; b=BaqNOzdr9F/0DuCRMA3VeT+t+XRWrXTulDTWosr2WPUO40AnerL6+r/X0axvwQykDIDT4604gyTBZ19xAhtUdwm+NmGp3O/T5A1KO1ydZTMN9gy8XNuQilqIP2NSLzj/HMub7OuOUxwgDeeQC7vaVEyreAoasSZ920w7hFNBEis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=beaver-labs.com; spf=pass smtp.mailfrom=edk@beaver-labs.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1620234066; s=zoho; d=beaver-labs.com; i=edk@beaver-labs.com; h=From:To:Subject:Message-ID:Date:MIME-Version:Content-Type; bh=tPyAtOK3FEYo8hGWIuw+K15c8yIuyhwJAbF9wgaZrJw=; b=G6ziyIQJqQUkyFMcOjTJfDQwMThN9PHd7k/u6DIxkZ+18W3v9fhKwltbpywx30Nz Cip2qm2Y3wlfIe/pkinzmHGHjfB2wIDYqpsLcTKoEfgYQE6m5qi8xnvSrf82Z9WXcf7 iyoVK3lXKvPWY8RJl7xBa63pOj5nj8k51mKU8qIM= Received: from Rasoir (lfbn-idf3-1-808-29.w90-3.abo.wanadoo.fr [90.3.133.29]) by mx.zohomail.com with SMTPS id 1620233915797265.19206164711113; Wed, 5 May 2021 09:58:35 -0700 (PDT) User-agent: mu4e 1.4.15; emacs 27.1 From: edk@beaver-labs.com To: help-guix@gnu.org Subject: How to lower a record to the build code ? Message-ID: <87eeelglsm.fsf@rdklein.fr> Date: Wed, 05 May 2021 18:58:17 +0200 MIME-Version: 1.0 Content-Type: text/plain X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.11; envelope-from=edk@beaver-labs.com; 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: , 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=1620235204; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=tPyAtOK3FEYo8hGWIuw+K15c8yIuyhwJAbF9wgaZrJw=; b=kCdaa6DcfHcUbvkV9q/zUdQ8KKpXI7S2spBzoeBcTIv3CDYReGKIc8TwMTpWhC+S1O15WV diVdV3YVUk5174rnJQVEsgJo5OYIiw8S2J/9OGbGtdElxoNAKi0q6kW1/J1on8T8hXpIJO yaoCqT19MGCMCw/7eMde63qlHyCreNcXPmiwFvwA89G2LPS3T4Ur90s3Dh6vVOJD5kULFg +Myf9iSk1gAsvdI4HoqbuiaJ+uwTQMWC5YEdHa8SO5Ti/w+vgDcunbvIgOnAuB48xdcoau gWBh4qD3eMFnIuEd15owbbhJPazxBm0jzfclzasbIWij+QqojQtYGR7HbkMp7A== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1620235204; a=rsa-sha256; cv=pass; b=mz3Sf/QCn6ARUyQMqk9VxisMcIsz7VOCqIlQq7y4ZQIuAJ1vjJyA0IVTPOKWWSUROZLk0l EruskL/1FVa7ti/17fc1+t2isrTzmbiimcZinoR7sSwoMGlJjE4K3FWIckZBbKTDdku9SE MD4V04CnhD36eFXmnFrVLHIE56d5K88Dbm4vh4dm2dOvDZs9WpJlCJmX5iT1tVOSEDoxhh BPrmcuJRCbp9S/DH9PFqgcPszEhn4bxqVkFDjJ3Gqa27Qk3tybZgL3UOvCY5oYsxAFtPrT muL4hN7GJIUPCMnPs/2W8LxJa+IGiytYTAw8IZU0nUzh16W5XhCCpVhbPetSHg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=beaver-labs.com header.s=zoho header.b=G6ziyIQJ; arc=pass ("zohomail.com:s=zohoarc:i=1"); 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: -2.47 Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=beaver-labs.com header.s=zoho header.b=G6ziyIQJ; 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: 2C6EC12D78 X-Spam-Score: -2.47 X-Migadu-Scanner: scn0.migadu.com X-TUID: HxWIg2jE27cw Hi, 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))))) I expect the gexp to compile to a file in the store whose contents are /gnu/store/....bash/ first second third The error is 1. &gexp-input-error: #< first-field: "first" second-field: ("second" . "third")> I tried to define a gexp-compiler, but I have clearly no idea of what I'm doing and I could sometimes make it work if I convert the record into a list, but not if there is a list within that list. I've read the relevant sections of the manual, and the code, and basically all instances of a call to define-gexp-compiler in the source code, but nothing comes close to what I need. I really could use some help, Thank you very much, Edouard. P.S. here is a minimal not-working example that you can copy paste in guix repl in order to reproduce my problem: (use-modules (guix gexp) (guix store) (guix derivations) (guix records) (guix monads) (gnu packages bash)) (define (build-gexp gexp) "Build GEXP using the local daemon." (let ((derivation (run-with-store (open-connection) (gexp->derivation "noname" gexp)))) (build-derivations (open-connection) (list derivation)) (derivation-output-path (assoc-ref (derivation-outputs derivation) "out")))) ;; There is a record type that I need on the build side (define-record-type* my-record make-my-record my-record? this-record (first-field my-record-first-field) (second-field my-record-second-field)) (define a-record (my-record (first-field "first") (second-field '("second" . "third")))) (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)))) ;; 1. &gexp-input-error: #< first-field: "first" second-field: ("second" . "third")> (build-gexp #~(with-output-to-file (string-append #$output "/file.txt") (lambda _ (display (function-of-a-record-and-a-build-time-path #$a-record #$bash)))))