From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id mO6kM55Gj2L+FAEAbAwnHQ (envelope-from ) for ; Thu, 26 May 2022 11:21:34 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id QABfM55Gj2JGWQEAauVa8A (envelope-from ) for ; Thu, 26 May 2022 11:21:34 +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 4F8EF167F2 for ; Thu, 26 May 2022 11:21:34 +0200 (CEST) Received: from localhost ([::1]:57764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nu9gS-0002z9-SW for larch@yhetil.org; Thu, 26 May 2022 05:21:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nu9f1-0001tP-7Z for guix-patches@gnu.org; Thu, 26 May 2022 05:20:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34939) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nu9f0-00016C-Tb for guix-patches@gnu.org; Thu, 26 May 2022 05:20:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nu9f0-0005rj-Jk for guix-patches@gnu.org; Thu, 26 May 2022 05:20:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55653] [PATCH] guix: Add syntactic sugar for profile generation. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 26 May 2022 09:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55653 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55653@debbugs.gnu.org Cc: Andrew Tropin , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Maxime Devos , zimoun X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.165355680022532 (code B ref -1); Thu, 26 May 2022 09:20:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 May 2022 09:20:00 +0000 Received: from localhost ([127.0.0.1]:57069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nu9ex-0005rM-J9 for submit@debbugs.gnu.org; Thu, 26 May 2022 05:19:59 -0400 Received: from lists.gnu.org ([209.51.188.17]:35406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nu9ew-0005rF-2q for submit@debbugs.gnu.org; Thu, 26 May 2022 05:19:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nu9ev-0001m3-NR for guix-patches@gnu.org; Thu, 26 May 2022 05:19:57 -0400 Received: from mail-ej1-x642.google.com ([2a00:1450:4864:20::642]:40906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nu9et-00014e-Kn; Thu, 26 May 2022 05:19:57 -0400 Received: by mail-ej1-x642.google.com with SMTP id wh22so1881281ejb.7; Thu, 26 May 2022 02:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:subject:to:cc:content-transfer-encoding:message-id :mime-version; bh=GxpEctlAdt0wUFnQfKpzU+e9a9lIOiX1Xv06mV+7FWI=; b=kLkWy8N3jhA6ZWDCzmtjJRG14VkMXotVSjOXXHs5yEkIRqDbvfw72sB/TGG+B2fQsf KaA1t4RmwjVM0+LwdLGACU3/25wr9tdCg0L28QraRXzw7vN1V2JXsvfow8T61RilTidw aCyZfmQ1Ig3etAZxLAJIANLhiN3kJw8CEvcYnPAUVdGSJwVJiGnOguycsaqOwieMpfVn mB5YUSPCcsYTntsIweSss6Sue1bqevUZWruLRd1HC1Sc0R+Y+0dFJ4W9DyROKf9Pe/HG TrsI4zsLv0sNC/bN18H2EM1FeuxWZyySmvA0oky+OGcgv9vT8qKVGcXIJCz30UF8lUut fbqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:subject:to:cc :content-transfer-encoding:message-id:mime-version; bh=GxpEctlAdt0wUFnQfKpzU+e9a9lIOiX1Xv06mV+7FWI=; b=bXEJVTNJc59ememgVi7tAly834eZpC5P5lKwaa21v5DqSBjj/IBjhWqyfb/W2kchrg DkCIUKyDQp5GJqk7AFElHNTRrqt72c3YdrWCdPD3fu5i5lraJxQqW3D5wAVlXzdXjLdF AnKxFdsa7M/vwf7PQuAxL7Wn3qDkGMpdsBadTfn43b9JKD5mbYAr/brYnvIGlKR50s1y QfzpVbuYuZCZxOnKQOnNtPpQykkZ6BCoZToWsQL7/R4QG53N6pYyZ8msFRDG3n2+FV52 6XybBkBYRGHS0ge5doZnpARe4kfb1T5n7y4n1xrGsAj5q0TTmSoPfnYPXKZrIvpmqgbd YXBw== X-Gm-Message-State: AOAM531osU8os0S6byRHbXRfsmLCcnObYhQdl07HbLrnaEAMfLyLNYkn DwRVEDeirjy766PS249qznh3fS4k4Jc= X-Google-Smtp-Source: ABdhPJxHc/0Got+LrL1FC330LQpbff3pMYE+BRSVMYonql6fDZAGnOAih6OCxocxkGJA64XysPSF3A== X-Received: by 2002:a17:907:8a01:b0:6ff:8b8:ca85 with SMTP id sc1-20020a1709078a0100b006ff08b8ca85mr9985812ejc.602.1653556791717; Thu, 26 May 2022 02:19:51 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id e12-20020a170906374c00b006fec41b21e1sm332952ejc.171.2022.05.26.02.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 May 2022 02:19:51 -0700 (PDT) From: Liliana Marie Prikler Date: Thu, 26 May 2022 11:01:02 +0200 Content-Transfer-Encoding: 8bit Message-ID: <10354f31e0be9bcb88b78da2fb8a2a3c3acbde10.camel@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::642; envelope-from=liliana.prikler@gmail.com; helo=mail-ej1-x642.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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, FREEMAIL_FROM=0.001, PP_MIME_FAKE_ASCII_TEXT=0.999, 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: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1653556894; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=GxpEctlAdt0wUFnQfKpzU+e9a9lIOiX1Xv06mV+7FWI=; b=PsQwidJoaMsDqPXX69nm8jhZEFnqjrfMIIj87uLNPM4Cm9/jz1NQxYA6kCHLPJdFrTFQt+ pUiFAETd5kHzS/MZKzyi7g9s3TrJ2nHzTRNfqrRb2bw2HTbbPMj44mdkcEMdpIrKBSVB2y do8kq2+fCJiAhiKDA81o9c9jy78irHmln6wyUsRL+NitssHuU0fkATEciEvxub2m3ZGvLL yvjG7G8FHsgqcl0X0j3e5JUQLHvyo/Z505ndpcZhZLmfxGtk6WRE97TPc5yDmcs/hUtZfS zXq+/X1fIU7rcIFSh+ovXMKOFdoLILOldIbNJpqCBueY3wDYk+gXS4UKJHKeRQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1653556894; a=rsa-sha256; cv=none; b=KUqQqQzxRBldTBo8W3+okaal144UVN+4oGJbso3UVaPkS8M4gLbefxXdvQE9JoE4AWl4da k/DAtzROubNxLeY/vTWIJt5+96qAO8U1gDUolzlvcwMhVa1ZAz/F73mWnZGMOaUy/4+Kcv wH8loaTFF7Z19OvnmGW52jx5Cs9b+WDlEBGkBF4J+hTWLnDsum/1R1hh+xWGaMtbr3VUq0 9jQZQUAjv0iGeE8/tgXu2UMiqtuBDfAGQfFePllleb/oaZG7bqFs/cpoDOXkT350R568zL 4UzylFeEESjI5rUZdTKoNCULgeDvkJU+nUAjAGX8JExp0+4TNa/xy+Rz0Xcimw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=kLkWy8N3; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 8.46 X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=kLkWy8N3; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 4F8EF167F2 X-Spam-Score: 8.46 X-Migadu-Spam: Yes X-Migadu-Scanner: scn0.migadu.com X-TUID: 55wJTkrKPGkF * guix/profiles.scm (%profile, package-compatibility-helper): New variables. (profile): Implement in terms of package-compatibility-helper. --- Hi Guix, this is a first step towards managing multiple profiles via Guix Home. It makes it so that regular Guix profiles can more easily be specified, though I'm not quite sure whether the mlet of packages->profile-entry should not also be used here. In any case, with this it should now be relatively easy for users to specify profiles such as (profile (name "emacs") (packages emacs emacs-magit emacs-org ...)) (profile (name "r") (packages r r-plyr emacs emacs-ess ...)) (profile (name "python") (packages python python-beautifulsoup4 ...)) ... What's still missing is a way to link them up with /var/guix/profiles/per-user and $HOME – for the latter, there would be a home-*-service-type. WDYT? guix/profiles.scm | 23 ++++++++++++++++++++++- tests/profiles.scm | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index bf50c00a1e..fbc343c456 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1974,7 +1974,7 @@ (define builder (manifest-entries manifest)))))))) ;; Declarative profile. -(define-record-type* profile make-profile +(define-record-type* %profile make-profile profile? (name profile-name (default "profile")) ;string (content profile-content) ; @@ -1987,6 +1987,27 @@ (define-record-type* profile make-profile (relative-symlinks? profile-relative-symlinks? ;Boolean (default #f))) +(define-syntax package-compatibility-helper + (syntax-rules (packages manifest) + ((_ () (fields ...)) + (%profile fields ...)) + ((_ ((packages exp) rest ...) (others ...)) + (package-compatibility-helper + (rest ...) + (others ... (content (packages->manifest + (delete-duplicates exp eq?)))))) + ((_ ((manifest exp) rest ...) (others ...)) + (package-compatibility-helper + (rest ...) + (others ... (content exp)))) + ((_ (field rest ...) (others ...)) + (package-compatibility-helper (rest ...) (others ... field))))) + +(define-syntax-rule (profile fields ...) + "Build a record, automatically converting 'packages' or 'manifest ' +field specifications to 'content'." + (package-compatibility-helper (fields ...) ())) + (define-gexp-compiler (profile-compiler (profile ) system target) "Compile PROFILE to a derivation." (match profile diff --git a/tests/profiles.scm b/tests/profiles.scm index d59d75985f..970a34b6cc 100644 --- a/tests/profiles.scm +++ b/tests/profiles.scm @@ -272,6 +272,22 @@ (define transform1 (manifest-pattern (name name)))) '("gcc" "binutils" "glibc" "coreutils" "grep" "sed")))) +(test-assert "profile syntax sugar" + (let ((p1 (dummy-package "p1")) + (p2 (dummy-package "p2"))) + (define (profile=? . profiles) + (define (manifest=? . manifests) + ;; Since we're using the same packages, we could also compare via eq? + (apply list= manifest-entry=? (map manifest-entries manifests))) + (apply manifest=? (map profile-content profiles))) + + (profile=? + (profile (content (manifest + (map package->manifest-entry (list p1 p2))))) + (profile (content (packages->manifest (list p1 p2)))) + (profile (manifest (packages->manifest (list p1 p2)))) + (profile (packages (list p1 p2)))))) + (test-assertm "profile-derivation" (mlet* %store-monad ((entry -> (package->manifest-entry %bootstrap-guile)) -- 2.36.1