From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id 0BEsKQCdHWaGWwEA62LTzQ:P1 (envelope-from ) for ; Mon, 15 Apr 2024 23:32:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id 0BEsKQCdHWaGWwEA62LTzQ (envelope-from ) for ; Mon, 15 Apr 2024 23:32:48 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713216768; h=from:from:sender:sender:reply-to: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; bh=xERw/Phm1vS41j0181GxAJ+qbh7qfiMkbq74hAR4TGY=; b=D2cddPAn9IGDGdhN2IAKuaLsBecTt6fk0E3P85G9dN2XV0rJL/h3syUCKHDCIAUEZFtJI2 5Dhn/kOHRtaE4838IorBcO47lia9J5Avp25MuMPe3vSrL+UXWLyCUWu1BoN6Vn6PL29zeN TlnmunumOlf73b4vYLQr7WSM6oHg8p4Z942HFq2uOINWFhdfT6APf+EqnBrJB0hE/hfrQo NFTUbakO14DAJYLvfuoxCT0L6AXhcrvWM+G0uSujxlOQRs+f/RSKTMMzQ9Bti50N3A6VMu p/fOSbn6Ie7OSjXEfQfOyrr4ZAfcdMk4CZKV5GPnMKK0xvcZ5QDgNcIESN6/eQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713216768; a=rsa-sha256; cv=none; b=c9jPQvC226y/7hSX8pLAm1na22Y+hWwgp/kjq/CVU9hNMlcz4tTWOCPOUoss7G9Jx8uN6v HAb655MMcCAfT3SvwpnBimOb37Nczf9RQjRw3xSziJya+9oFTzuz0hidz695hYugDtwHhW 83FMT1Hd40Wp5A8UuOqaElL4bL8q8+3df2zbwa1YiAP03rKdAjJXZOTtDzRaP9LOn0bLig vsElD7FN3cDNpzgZ3WtUN4FgZZT4sBy2eiFz4F/7nU36NdE9lDbTQqsNv+Zmiap2lXa7ky vzs1TkxIe7dZgsvN8YXeCYVktW/31V0+iJGLLeYMzyED0BjTIF71WTPCPqRo+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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"; dmarc=pass (policy=none) header.from=gnu.org 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 3A8A967F9A for ; Mon, 15 Apr 2024 23:32:47 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwTvn-0006mR-QF; Mon, 15 Apr 2024 17:32:04 -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 1rwTvm-0006mD-5W for guix-devel@gnu.org; Mon, 15 Apr 2024 17:32:02 -0400 Received: from 17.mo583.mail-out.ovh.net ([46.105.56.132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwTvj-0004On-3d for guix-devel@gnu.org; Mon, 15 Apr 2024 17:32:01 -0400 Received: from director8.ghost.mail-out.ovh.net (unknown [10.108.9.127]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 4VJL366lrCz1ND6 for ; Mon, 15 Apr 2024 21:31:46 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-c4d6t (unknown [10.110.178.103]) by director8.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 888651FD54; Mon, 15 Apr 2024 21:31:45 +0000 (UTC) Received: from ngraves.fr ([37.59.142.97]) by ghost-submission-6684bf9d7b-c4d6t with ESMTPSA id pv1zJ8GcHWa+fQAA0WQuXg (envelope-from ); Mon, 15 Apr 2024 21:31:45 +0000 X-OVh-ClientIp: 81.67.146.208 To: spacecadet , guix-devel@gnu.org Subject: Re: Functional package interface In-Reply-To: <0076d418-547a-1de2-6977-afe10d1a4222@purge.sh> References: <0076d418-547a-1de2-6977-afe10d1a4222@purge.sh> Date: Mon, 15 Apr 2024 23:31:45 +0200 Message-ID: <871q76pb26.fsf@ngraves.fr> MIME-Version: 1.0 Content-Type: text/plain X-Ovh-Tracer-Id: 11295590819071648309 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudejvddgudeifecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvufgjfhffkfggtgesthdtredttddttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeelveduhffhheeggeevueevteehvddvfeeuieeihefhtdehhefggfevgfdugefgueenucffohhmrghinhepghhnuhdrohhrghdpshhrrdhhthdpvhhulhhnihigrdhshhenucfkphepuddvjedrtddrtddruddpkedurdeijedrudegiedrvddtkedpfeejrdehledrudegvddrleejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpehnghhrrghvvghssehnghhrrghvvghsrdhfrhdpnhgspghrtghpthhtohepuddprhgtphhtthhopehguhhigidquggvvhgvlhesghhnuhdrohhrghdpoffvtefjohhsthepmhhoheekfedpmhhouggvpehsmhhtphhouhht Received-SPF: pass client-ip=46.105.56.132; envelope-from=ngraves@ngraves.fr; helo=17.mo583.mail-out.ovh.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Reply-to: Nicolas Graves From: Nicolas Graves via "Development of GNU Guix and the GNU System distribution." 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 X-Migadu-Spam-Score: -6.87 X-Spam-Score: -6.87 X-Migadu-Queue-Id: 3A8A967F9A X-Migadu-Scanner: mx13.migadu.com X-TUID: wsmhJWJepS7l Hi spacecadet! Isn't what you're trying to do already in Guix? Have a look at package-inputs-rewrite right there : https://guix.gnu.org/manual/devel/en/html_node/Defining-Package-Variants.html I've also been working on general package propagation in RDE, it's still a work in progress, but it's not far from it : https://lists.sr.ht/~abcdw/rde-devel/patches/49956 Best regards, Nicolas On 2024-04-14 07:02, spacecadet wrote: > Hi guix > > I started working on a "functional interface" to guix packages, as an > approach to globally modifying packages in an environment, similar to > nix overlays or the parameterization project. > Right now it's just a syntax rule that you can wrap a bunch of package > definitions in with some inputs in the style of a let. > > > (define-syntax define-public-package-set > (syntax-rules () > ((define-public-package-set pkgset > ((input ...) > ...) > (package-name package-def) > ...) > (begin > (define-public pkgset > (lambda* (#:optional packages > #:key (input ...) > ... > #:allow-other-keys) > (define package-name package-def) > ... > (cond ((and packages (list? packages)) > (map (lambda (package) > (cond ((eq? package 'package-name) > `(package-name . ,package-name)) > ...)) > packages)) > (packages > (cond ((eq? packages 'package-name) > package-name) > ...)) > (else > `((package-name . ,package-name) > ...))))) > (set-procedure-property! pkgset 'package-set? #t) > (define-public package-name > (pkgset 'package-name)) > ...)))) > > > Tried rewriting the guile packages module with it, link to the full > code further down but here's a snip: > > > ;; existing module > (define-module (gnu packages guile) > #:use-module ((guix licenses) #:prefix license:) > #:use-module (gnu packages) > ... > > ;; package-set definition > (define-public-package-set gnu-packages-guile > ((bash-minimal bash-minimal) ;; inputs > (gawk gawk) > (gmp gmp) > ... > (url-fetch url-fetch)) > > ;; packages > (guile-1.8 > (package > (name "guile") > ... > > > You end up with a public "gnu-packages-guile" function that takes > keyword-argument inputs like: > > (gnu-packages-guile #:gawk (@ (gnu packages bioinformatics) bioawk)) > ;; => all the packages in gnu/packages/guile.scm, but every instance > ;; of awk is replaced with bioawk > > > Then returns an alist of all the packages in the set with the inputs > appropriately "modified". For the keys in the alist I'm using the > variable names as symbols instead of the package names like in inputs, > because I feel that's more generally appropriate in the case where a > package-set might contain something that's not a package record. > Will probably write a helper function that spits out input pairs. > > It can also take a single symbol or list of symbols as an optional > argument to produce either a single package or list of requested > packages: > > > (gnu-packages-guile 'guile-3.0) > ;; => # (gnu-packages-guile '(guile-2.2 guile2.2-json)) > ;; => (# > > Packages still get define-public'd, I assume in a way that would > preserve the existing working condition of the repository (although > there is one issue right now, more below) so this could hopefully turn > into a drop-in addition after some more work. I tried to make very few > changes necessary to the existing code to for the same reason. > > Eventually, the goal is to be able to create an operating system > definition (or manifest, or anything else) using this, with a > hypothetical case like: > > > (use-package-modules base network etc.) > > (define my-package-set > (packaget-set-append gnu-packages-base > gnu-packages-network ...)) > > (with-package-set > (my-package-set #:mesa something-else) > (operating-system > (...))) > > > Adapting more complicated package modules would probably be a task, but > I'm invested enough to keep working on it. > > There are also a few problems with the current implementation, and I > think they all boil down to one issue: > If packages A and B are both in the same module, and B is an input to > A, I can't replace B. > There may be a solution, it might be as simple as providing a dummy > input for each package in the module, I don't know, open to ideas. > > Another more minor problem is that it won't pull: > > > In ice-9/boot-9.scm: > 222:29 19 (map1 _) > 222:29 18 (map1 _) > 222:29 17 (map1 _) > 222:29 16 (map1 _) > 222:29 15 (map1 _) > 222:17 14 (map1 (((gnu packages guile)))) > 3327:17 13 (resolve-interface (gnu packages guile) #:select _ #:hid > In ice-9/threads.scm: > 390:8 12 (_ _) > In ice-9/boot-9.scm: > 3253:13 11 (_) > In ice-9/threads.scm: > 390:8 10 (_ _) > In ice-9/boot-9.scm: > 3544:20 9 (_) > 2836:4 8 (save-module-excursion _) > 3564:26 7 (_) > In unknown file: > 6 (primitive-load-path "gnu/packages/guile" # In ice-9/eval.scm: > 619:8 5 (_ #f) > 626:19 4 (_ #) > 619:8 3 (_ #(#(#) # > 632:34 2 (_ #(#(#) # > 223:20 1 (proc #(#(# > In unknown file: > 0 (%resolve-variable (5 (gnu packages bash) bash-minimal . > > ERROR: In procedure %resolve-variable: > error: bash-minimal: unbound variable > > > So I'm probably doing something bad. > Seems like the first variable in the "inputs" fails to resolve > somewhere? I don't even have a guess what's going wrong. > > My code is available at https://gitlab.vulnix.sh/spacecadet/guix > Open to comments or ideas, and if anyone can give me a hand figuring out > the pull issue I'd be grateful. > > - sc > -- Best regards, Nicolas Graves