From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.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 SJIlLUUNTGRrMQEASxT56A (envelope-from ) for ; Fri, 28 Apr 2023 20:15:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id CNFFLEUNTGTXnwAAG6o9tA (envelope-from ) for ; Fri, 28 Apr 2023 20:15:33 +0200 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 538233DC7F for ; Fri, 28 Apr 2023 20:15:33 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psRSj-0002Fa-E9; Fri, 28 Apr 2023 13:00:49 -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 1psRSg-0002ER-Ck for guix-devel@gnu.org; Fri, 28 Apr 2023 13:00:47 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1psRSe-0007M2-7w for guix-devel@gnu.org; Fri, 28 Apr 2023 13:00:46 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f17b5552e9so23559495e9.1 for ; Fri, 28 Apr 2023 10:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682701242; x=1685293242; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=vYDnRJ6dmoHCBA8sG3qQLrCKC979aLua7A1nYzstSSc=; b=DAf/KLkd600y1Sl7pkVFOvGnQoAzW3RX3GtCoYG4HWcj8I2oBTae7TRUiCbz8M80gG 1RrbnPuKZlDEObK2cbbG11xg2yoKJqJDMispqWdS9Sg+LxYmCRyi34Li3xeJY7Mtg8Wk 62DL0V51wm7Gx257j7tj0g0APTn1t/aVTHgP/yyfP6Z+ZyKcgi8wUVn+zWh1lnac+PuU cruDTB+fi/MinMcbtQgIQ63pEaeNpdj+o7p/cIDVjj512Z2uUtdGTLBvudtxqrjx2++w JDShO3+QOMAGG93quS1JL3axWpCdGYgLdIXdsFjWm11XN4vX+qVhR8tT7AZI5lq8Kay2 oP4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682701242; x=1685293242; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vYDnRJ6dmoHCBA8sG3qQLrCKC979aLua7A1nYzstSSc=; b=j09Oi0ClKkOtoPIBZyooKZzdSk6f7BsbPI5xvJOdlqSlr81lwxJrIRuUznxR5e6uZ+ beUOMlXdCauwRsgY5AvybAuHp/ZR6gimHsOPwaP0fVVRUxP5YRNuZlIm7JU/Yy9hv4r0 kViLP/BFsdWKwlZdJiWxlAzYdpILrQ4S5H4rzaoglPcQZwDSbq4aM+t/FQR+wiV0Ek/b jh5sd6QdtSpJTt8FW++vnIBXMxWbcqZhIoEq++7kMcrkvY6mc+BHhaeNM09f3u2ZVrZq 7/AscWgMTSM7PdKcnFyL0hsdXtf1dtHIOmP7Thh/ZkfnmQMFy+leb69Fme2xxfgT5xWw /jEg== X-Gm-Message-State: AC+VfDxw05mexHABslzVcAzhwYYg367Fv6QFu2wQcJIhaTlNUT6f813Q +igBSFlxqGGeXJ/kRQ9N+0w= X-Google-Smtp-Source: ACHHUZ67jQR0swaHSiSNl9zObLOjjboKQuASgCORTvWT65RImxubI9B8eVAfvyfLErg66JQRx1UtLQ== X-Received: by 2002:a05:600c:458e:b0:3f1:7518:e37f with SMTP id r14-20020a05600c458e00b003f17518e37fmr5076747wmo.1.1682701241594; Fri, 28 Apr 2023 10:00:41 -0700 (PDT) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id l2-20020a05600c4f0200b003ee74c25f12sm28688059wmq.35.2023.04.28.10.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 10:00:41 -0700 (PDT) From: Simon Tournier To: Maxim Cournoyer Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , =?utf-8?Q?Bj=C3=B6rn_H=C3=B6fling?= , guix-devel@gnu.org, Lars-Dominik Braun Subject: Re: Adding content-addressed URLs to https://guix.gnu.org/sources.json In-Reply-To: <87354oqdal.fsf@gmail.com> References: <20230312220021.22bfff4f@tangletp> <878rfwgbng.fsf@gnu.org> <86lej8y75p.fsf@gmail.com> <87cz3t44hi.fsf_-_@inria.fr> <86pm7sb7vf.fsf@gmail.com> <87354oqdal.fsf@gmail.com> Date: Fri, 28 Apr 2023 15:39:46 +0200 Message-ID: <87v8hg9lct.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=zimon.toutoune@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-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=1682705733; a=rsa-sha256; cv=none; b=DdZ+abV2cxAHU/BcqOHSWtpy8+Yd8PQzYtPtbgDw2ydTxlPTaNl060mZ0fz2YgeIat5/X1 jOCKgKJLUGpLiKNR36Em0Dbi609sxFkN7eDvE74q+u2vO/dk1EICGlwNn0+Coy3SYi+InQ LJgGCAESGsm8Y9QnrCTXwAsx8ptLbmO5Tt7/vfiIkUtiXWHNyD+NSlS+xFuDFmz+pFO5iU AkStyAauOVq84a0CmgGPUClQOV5O8zTQA3f5Aww2gwu1Dic8Xt/ZSIGRyx+IfwaHHaepxV 9vWbLMneSgZFQxM2xQB54BllxcSCn9XEjRrjQftJfriM1uSYbAQQRLJX0zCBCg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="DAf/KLkd"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682705733; 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=vYDnRJ6dmoHCBA8sG3qQLrCKC979aLua7A1nYzstSSc=; b=Oiyr2MCPnUzppDmQ/YPWqZm4GsRV94+cFnbKTfblWYA/GtObdwgox9Xqgp47EbP5j6S+4h mKSY9/bRXeAUOztdDR4i6r/UrO64vHfF91PIPF3aw7gP0/Gt/vryqX4te8qQ4AvH7mxb7G qxxBlihex8Mv65pmaYQkLIQb94uMurDfvr8BLwwDaXktUBz52Y/wHtlKQ+v4QLV2OdxYcy Uuqhfb2XeFAVnhdJE5JelB0x/1kUc9+oMmIrOA5x72G1H+XVG6Ylu9AkeD7ueqWvd5fLpK fEB1Z0r7gD3vPYqusCbkOvpRhxhGxMqe6PotjJgGCA7UTspqPMoRT9M2+WRv5g== X-Migadu-Spam-Score: -7.62 X-Spam-Score: -7.62 X-Migadu-Queue-Id: 538233DC7F X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="DAf/KLkd"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-TUID: +Gqnq6i2XYgq --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludo, Maxim, all, On mar., 25 avril 2023 at 14:40, Ludovic Court=C3=A8s wrote: >> Somehow, it reveals 3 currently uncovered cases: computed-file appearing >> as, >> >> 1. =E2=80=99origin=E2=80=99 in source field (ruby-sorbet-runtime) >> 2. =E2=80=99inputs=E2=80=99 (racket-minimal) >> 3. =E2=80=99snippet=E2=80=99 in origin in source field (chromium) > > I think #1 and #2 are okay: we can use any file-like object there, not > just origin/package. Of course, is meant to be the best choice > for =E2=80=98source=E2=80=99, and the best choice for =E2=80=98= inputs=E2=80=99. But I think > it=E2=80=99s fine to occasionally resort to some other abstraction when t= hese > two are not adequate. I agree that any file-like object is nice. Somehow, the issue is to =E2=80=9Cunpack=E2=80=9C the information of this object. For instance, --8<---------------cut here---------------start------------->8--- scheme@(guix-user)> (define ruby-sorbet-runtime (@@ (gnu packages ruby) rub= y-sorbet-runtime)) scheme@(guix-user)> (package-source ruby-sorbet-runtime) $1 =3D #< name: "ruby-sorbet-runtime-0.5.10610.2023010617452= 0-1fa668010-checkout" gexp: # ur= l: "https://github.com/sorbet/sorbet" commit: "0.5.10610.20230106174520-1fa= 668010" recursive?: #f> # () 7fd7ad6b81e0>:out> "/gems/sorbet-" #) #)) gnu/packages/ruby.scm:14071:5 7fd7ae7= 34480> guile: #f options: (#:local-build? #t)> --8<---------------cut here---------------end--------------->8--- and as far as I understand, this case cannot be handled by some generic code. The extraction of the =E2=80=9Creal=E2=80=9D origin needs manual and= specific extraction because of this =E2=80=99computed-file=E2=80=99. For sure, =E2=80=99source=E2=80=99 can use any file-like object because som= e use-cases require that. However, I would be tempted to use an =E2=80=99origin=E2=80= =99 as a preferred choice =E2=80=93 i.e., when it=E2=80=99s possible and try to make= it possible. ;-) Because, somehow, it =E2=80=9Cnormalizes=E2=80=9C the source = information and eases its extraction. On mar., 25 avril 2023 at 09:52, Maxim Cournoyer wrote: >> This pattern appears to me wrong. It should use =E2=80=99snippet=E2=80= =99. And if the >> point is to have a meaningful path in /gnu/store, as it is the case with >> icecat or linux or emacs-company-box, the current way is >> =E2=80=99computed-origin-method=E2=80=99 from (guix packages). >> >> For =E2=80=99ruby-sorbet-runtime=E2=80=99, the fix seems =E2=80=99comput= ed-origin-method=E2=80=99. > > Per the source, IIRC, 'computed-origin-method' is also considered a hack > or workaround around the fact that a snippet can't affect the name of a > source. But it's a well established one. That was indeed the rationale > here (to have meaningful top level directory names matching the source), > which is worth it in my opinion. I agree that =E2=80=99computed-origin-method=E2=80=99 had been considered a= s a hack. I guess, mainly because at the time, the need seemed singular and that =E2=80=99snippet=E2=80=99 were maybe less powerful. For what my opinion is= worth, instead of, --8<---------------cut here---------------start------------->8--- (define (make-sorbet-gem-source gem) "Return the source of GEM, a sub-directory." (computed-file (string-append "ruby-sorbet-" gem "-" sorbet-version "-checkout") (with-imported-modules (source-module-closure '((guix build utils))) #~(begin (use-modules (guix build utils)) (copy-recursively (string-append #$sorbet-monorepo "/gems/sorbet-" #$gem) #$output))))) (define-public ruby-sorbet-runtime [...] (source (make-sorbet-gem-source "runtime")) --8<---------------cut here---------------end--------------->8--- I would try to =E2=80=9Cnormalize=E2=80=9D this behaviour. Well, it=E2=80= =99s not clear for me if =E2=80=99computed-origin-method=E2=80=99 is suitable as a basis for that= ; somehow it would appear to me the direction for these kind of use cases. Anyway, from my point of view, considering this very specific use-case of ruby-sorbet-runtime, the pattern using =E2=80=99computed-file=E2=80=99 a= s =E2=80=99source=E2=80=99 =E2=80=93 only for having the correct store pathname =E2=80=93 is not something that I would introduce when it is avoidable. And, maybe I am missing a point, but it appears to me avoidable: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build ruby-sorbet-runtime -S /gnu/store/ni5mz1j7lbdrdqsvdm5dq1d2ack8c8q6-ruby-sorbet-runtime-0.5.10610.2= 0230106174520-1fa668010-checkout $ guix hash -r $(guix build ruby-sorbet-runtime -S) $(./pre-inst-env guix b= uild ruby-sorbet-runtime -S) 0agzz44qqq5pxqzzpxwhzlbwwc7x20jrmbmaxj6q8a5bq9ydzws7 0agzz44qqq5pxqzzpxwhzlbwwc7x20jrmbmaxj6q8a5bq9ydzws7 --8<---------------cut here---------------end--------------->8--- using a =E2=80=99snippet=E2=80=99 =E2=80=93 see below. Basically, =E2=80= =99file-name=E2=80=99 does the job for the correct name and the other part is just moving content around. Well, I guess this snippet could be simplified. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=p.patch Content-Description: snippet.patch diff --git a/gnu/packages/ruby.scm b/gnu/packages/ruby.scm index 1dcd5f76a5..f61044f76b 100644 --- a/gnu/packages/ruby.scm +++ b/gnu/packages/ruby.scm @@ -14078,7 +14078,35 @@ (define-public ruby-sorbet-runtime (package (name "ruby-sorbet-runtime") (version sorbet-version) - (source (make-sorbet-gem-source "runtime")) + (source + (origin + (inherit sorbet-monorepo) + (file-name (git-file-name name version)) + (modules '((guix build utils) + (ice-9 ftw))) + (snippet + #~(begin + (use-modules (guix build utils)) + (let* ((name "runtime") + (gems "gems") + (gem (string-append gems "/sorbet-" name))) + (for-each + (lambda (x) + (unless (or (string=? "." x) + (string=? ".." x)) + (delete-file-recursively x))) + (scandir "." + (lambda (x) + (and (eq? (stat:type (stat x)) 'directory) + (not (string-prefix? gems x)))))) + (for-each + delete-file + (find-files "." + (lambda (x _) + (not (string-prefix? (string-append "./" gems) x))) + #:directories? #f)) + (copy-recursively gem ".") + (delete-file-recursively gems)))))) (build-system ruby-build-system) ;; 25 out of 841 tests currently fail, seemingly due to invalid ;; assumptions about file names in the build environment (see: --=-=-= Content-Type: text/plain Cheers, simon --=-=-=--