From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id ePVHEyDFHGT/SgEASxT56A (envelope-from ) for ; Thu, 23 Mar 2023 22:31:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iGUnEyDFHGSs0AAAauVa8A (envelope-from ) for ; Thu, 23 Mar 2023 22:31:12 +0100 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 5B7FE10C76 for ; Thu, 23 Mar 2023 22:31:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfSW9-0000Uh-GB; Thu, 23 Mar 2023 17:30:41 -0400 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 1pfSW6-0000UX-Oo for help-guix@gnu.org; Thu, 23 Mar 2023 17:30:39 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfSW4-0003IN-MI for help-guix@gnu.org; Thu, 23 Mar 2023 17:30:38 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E42115C01F6; Thu, 23 Mar 2023 17:30:32 -0400 (EDT) Received: from imap52 ([10.202.2.102]) by compute1.internal (MEProxy); Thu, 23 Mar 2023 17:30:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:content-type:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1679607032; x= 1679693432; bh=/pafca43GrpfZsPk9jpRFIVnECwgCsifgFq9QA5DCbk=; b=D UqvrqPphgIc/IM6xDChqQZkLOdt7B2mHtFE4LrZQjjBVisRpoEPS2pSwA+ComgD4 gnSBI8FOb9XWYX3Ex2ylyc2Dh91rKR6E90PU07GjOtCuXYjvywRFY81QxO3j/vBb D7Kwq7w0k0H5hbzzC5oBaSANHgYhPcoPU9/3QLyeJSkxh5G//A8TgwCZEsbSq9Ev HRbiDj7rcDKUF9FLhtbMMBRPoNZIdgTRCyh4RkF1HPlbsyd+GbDLjDYkHXjYfPP9 eDXQFC7yPreJZ6BIfxx3IyjCtbTjCM5pm0qM2Wa91ZIVAygc8ARJvqNUHJBmv7kt FwTw0dYoNGUextIrlMC2g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1679607032; x=1679693432; bh=/pafca43GrpfZ sPk9jpRFIVnECwgCsifgFq9QA5DCbk=; b=MCC87UqK5wsyFzGvQtiMCAXYKJpfk G6rPnkC7AYHlRa4QaQGcLt432FSiyOa5iRT8tjuoqhA15ZMkFtdnytQvjWJ/Yh8+ As3XPGQuYKt4PfTlMIIKBGnFqn2agxigmjs4pl4ajYhqfNO3Grye7oiwbp+3cvXv zLcPenPCcYjvsXee3eJucNvfwW5IjhArQcJYSsBBdfGdQaP9Tsx6gnYBzODQl3F4 Vc/Wfyi+eY9Tu2LUVD9TjgYSUegNN802qgnhNV8k41wEdhPHfthAbNdT+8VgbLOK 5/5Q/907VaG52B3baVGmNimWWL0oRJ03mBU0doW4Wm2oSOydpH5+o/4AQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeggedgudeglecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesth dtredtreertdenucfhrhhomhepfdfrhhhilhhiphcuofgtifhrrghthhdfuceophhhihhl ihhpsehphhhilhhiphhmtghgrhgrthhhrdgtohhmqeenucggtffrrghtthgvrhhnpefhte dugfdtudegledvgeefvdeuveehveefgfduieeuhfeihfduheevteehkefhvdenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehphhhilhhiphesph hhihhlihhpmhgtghhrrghthhdrtghomh X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5EEC6C60091; Thu, 23 Mar 2023 17:30:32 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-236-g06c0f70e43-fm-20230313.001-g06c0f70e Mime-Version: 1.0 Message-Id: <36a1b658-1137-4f8e-8217-823b6611ad60@app.fastmail.com> In-Reply-To: <874jqcs4s7.fsf@posteo.net> References: <874jqcs4s7.fsf@posteo.net> Date: Thu, 23 Mar 2023 17:30:11 -0400 From: "Philip McGrath" To: Kyle , help-guix@gnu.org Subject: Re: Need some help packaging parts of a scientific workflow Content-Type: text/plain Received-SPF: pass client-ip=66.111.4.27; envelope-from=philip@philipmcgrath.com; helo=out3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1679607072; a=rsa-sha256; cv=none; b=QQdh1DVAF3j0Dv0i1Wjk5vW9jGu9YB6DISJ1ArHA33PuupugC8mthLunG7XR0QiYsbuEjM yHXYp/eCtGmEeXyEK69NdCU4IG8seWR8EvhEMpOKean7/F6pANtJ9IAD2hgROlGftRf+Sg E+LnYlU1905acT6rDToNiYAhBoBaw60nr1eJ+ZR8/YdEaWPbsZE5Yv8fYUI046GwIbAfCJ EZTwPd/c7Tsiky6OgHE5ML+OBQMoTbavpyKPboY2h3zuJErpIgdhWHhKSsjcNAcPvo3n8X TfnRO5Y0w+Rcs7TEa+COoUtjkGijkvloWqpkCK6duENOBYg8dwsR8G86xZ5Cyg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm2 header.b="D UqvrqP"; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b=MCC87UqK; dmarc=none; 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=1679607072; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/pafca43GrpfZsPk9jpRFIVnECwgCsifgFq9QA5DCbk=; b=pveTibEfDOnsUpbtzF7zXRN73OljePV53NfvihgdTCq5zVW0Vj1P2gYdo+0YI0/jQR0tW+ SEAaRFbmXcftwUevYW9e2ure9fy8LFcYykUOL4VZbKFTC0BF1z2zoT1oSvYlHdVz0aR9YE zI55FfwSSmW6/lAHzDYvD7FXNsJmOc2AGG7nYfd3runuhDzOE4zJU9ddWnTQhVb+actHlf zM0CIjtBQyLNYQn7kxj3hxiqeG61tuPQmFhPqvqK5A8TIo8sAaWF/051fdT+Hx13FUuiz4 EOEry74wuqv00RALlCflhRH6V7DmaNklAvYTLrOEdk8AdyQedfObkNOXDrxmgA== Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=philipmcgrath.com header.s=fm2 header.b="D UqvrqP"; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b=MCC87UqK; dmarc=none; 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" X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -1.64 X-Spam-Score: -1.64 X-Migadu-Queue-Id: 5B7FE10C76 X-TUID: riF8gZ3XeKDF Hi Kyle, On Wed, Mar 22, 2023, at 5:29 PM, Kyle Andrews wrote: > Dear Guix, > > Part of my scientific workflow involves compiling a small Racket script > for a command line program into its executable and placing that on > PATH. I am always glad to hear of more people using Guix and Racket together! > I had bundled this script inside an R package which made sure it > got compiled and everything was correctly configured at library load > time. > Tangential to your actual question, I think this is not necessarily a terrible practice. There is not much difference between running `my-script` and running `racket -y "path/to/my-script.rkt"`, and, if you do that or `raco make` during the build process of your R package, you'll get compiled files properly. There are tradeoffs to weigh, including support for R users without Guix. But there are also good reasons to decide to separate the Racket script from the R library, so that's what I'll explain below. > From reading the documentation a lot, I think the actual compilation > step can be done using the "invoke" procedure like so: > > ``` > (invoke "raco" "exe" "{package_location}/custom-shell-tool.rkt") > ``` > > What I'm struggling with the most is understanding all the boilerplate > code I need to place around that fundamental call. > I'll start with a working example suitable for `guix build -f`, then answer your specific questions. ``` ;; SPDX-License-Identifier: (CC0-1.0 OR (Apache-2.0 OR MIT)) ;; SPDX-FileCopyrightText: Philip McGrath (use-modules (gnu packages racket) (guix build-system copy) (guix gexp) (guix packages)) (package (name "racket-hello") (version "1.0") (source (plain-file "hello.rkt" "#lang racket (displayln '|Hello from Racket!|)")) (inputs (list racket)) (build-system copy-build-system) (arguments (list #:install-plan #~'(("hello" "bin/")) #:phases #~(modify-phases %standard-phases (add-before 'install 'build (lambda args (invoke "raco" "exe" "hello.rkt")))))) (home-page #f) (synopsis "Hello world in Racket") (description "This is a trivial example of using @code{raco exe} with Guix.") (license #f)) ``` In fact this package would be a reasonable candidate for `trivial-build-system`, but I've stuck with `copy-build-system` because the boilerplate for `trivial-build-system` is very different than for all other build systems. Likewise, I'm assuming you know how you want to build your executable, but you might consider the `--launcher` flag for `raco exe` and an explicit call to `raco make`: in particular, it might take use less total disk space than an ELF executable. Note that you do have to use `racket`, not `racket-minimal`, because `racket-minimal` doesn't include the `raco exe` command. > (source > (local-file "package_location")) ; how to refer to local files? In general, `local-file` is the right mechanism; specifics depend on your situation, including how you are expecting your package definition to be used. For a single file, `(local-file "path/to/script.rkt")` is probably what you want, where the path is relative to the Guile file containing the `local-file` expression. For a directory, consider the `#:recursive?` and `#:select?` arguments. > (invoke "raco" "exe" > (string-append > #$package-folder ; how to refer to the build itself? > "custom-shell-tool.rkt")))))) The `unpack` phase from `gnu-build-system` handles this: if the package source is a directory, you're inside a copy of it; if it's a file, you're in a temporary directory containing it. > > I'm especially interested in figuring out how I can productively learn > to experiment productively with this stuff for myself. > Personally, I often insert a phase that calls `error` to stop the build, perhaps printing out interesting values first, and use `guix build --keep-failed` to explore the build environment. -Philip