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 ms0.migadu.com with LMTPS id kGTlB1AhCmJrHwEAgWs5BA (envelope-from ) for ; Mon, 14 Feb 2022 10:30:56 +0100 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 6PqkBFAhCmIuAQAAauVa8A (envelope-from ) for ; Mon, 14 Feb 2022 10:30:56 +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 324E63A301 for ; Mon, 14 Feb 2022 10:30:54 +0100 (CET) Received: from localhost ([::1]:51366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJXh7-00086I-A4 for larch@yhetil.org; Mon, 14 Feb 2022 04:30:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJXgL-0007Yn-AT for bug-guix@gnu.org; Mon, 14 Feb 2022 04:30:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJXgK-00061N-V4 for bug-guix@gnu.org; Mon, 14 Feb 2022 04:30:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nJXgK-0006GW-Lf for bug-guix@gnu.org; Mon, 14 Feb 2022 04:30:04 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#53210: [WIP PATCH 3/4] gnu: current-guix: Support when running outside a checkout. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 14 Feb 2022 09:30:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53210 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe Cc: Josselin Poiret , 53210@debbugs.gnu.org Received: via spool by 53210-submit@debbugs.gnu.org id=B53210.164483097623970 (code B ref 53210); Mon, 14 Feb 2022 09:30:04 +0000 Received: (at 53210) by debbugs.gnu.org; 14 Feb 2022 09:29:36 +0000 Received: from localhost ([127.0.0.1]:39731 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJXfs-0006EW-Cs for submit@debbugs.gnu.org; Mon, 14 Feb 2022 04:29:36 -0500 Received: from jpoiret.xyz ([206.189.101.64]:37042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJXfq-0006EO-1C for 53210@debbugs.gnu.org; Mon, 14 Feb 2022 04:29:34 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 0538E1851E0; Mon, 14 Feb 2022 09:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1644830973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DWANRgEi0auPDrqPUvJYgOvaGO5cVJgxO2kqKSgK4YE=; b=RnPMCxb9NR/PFG2wvRnCKc6pPuSgbYIb+n71V3aPIUrBtpRrvax0gwyXnqTFIn032zrXm4 OmgS0wfIjk6oVApyZGpantqJD71Qy7sCH1qXZfSs1w5rFrZ9New9Yf3oKtAWMBKQfjjA1j fZIaeRV/NYtjG63q30dSutD7qEwV1Vj1H1Ve3VYjh+utgxVSXalDQURoV9ZtwGYtC7wxMG WPWXpfZyiI4IQ1KQTQS/2C4am6wVR41e5XPQJNUGNqfhyW8m1ndURJEW8mg79nHa5kJHfO HrYvAQ9IM33dvOSNMwHkS7pujzF8d68j6dDlgkdsAT062aAHnVprelkdo9fCxw== Date: Mon, 14 Feb 2022 10:29:07 +0100 Message-Id: <20220214092908.16801-4-dev@jpoiret.xyz> In-Reply-To: <20220214092908.16801-1-dev@jpoiret.xyz> References: <87lezkrgvj.fsf@gnu.org> <20220214092908.16801-1-dev@jpoiret.xyz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" Reply-to: Josselin Poiret From: Josselin Poiret via Bug reports for GNU Guix X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644831054; h=from:from:sender:sender:reply-to: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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=DWANRgEi0auPDrqPUvJYgOvaGO5cVJgxO2kqKSgK4YE=; b=VXZ8KDC4JQjt5RroP6eCgs4Fq1JzFqgXrpQdMYzdUhjUQ5rK753imAhMOlbY8ou9q0g20m w/14QR1s8HzS1P2S7UpoyXU6AC0+GmbDCxNAGTIDX+HgOQwzef0C6ffdZYnFiZFv5fdXSa drGysJ4pQVVpI1lgVhAOZ8hnqYzbtamikjUH0uJtnuaDVs1gJmcgaNL9KiTQ6I0kGR4jcC jKpM5bf45SuN+R9d7AkBYu+3B4S03cFpLCtiIPIDJT7kWK1qBjcCFcV3eIBYPKdgIcWHkz CAqTmpmiOwvwzqJOjZv9zcKJimbxomCp4fqWGZwZ1b5L7ao7HhDdoZOIb3+5Nw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644831054; a=rsa-sha256; cv=none; b=KUe6MSwrlTawnhJpyECb9wYjIbnbA/0EjZOW9+Q1rxK4YfFDJWmgTb+tgSetf5bvdhPJPL 995JIIWyNmjNdUtuW09fX3i+vPr+sM5sXiAMsOfREQXTCZMocXX26mJnB47jevszMZhJEU KMIC6nlP6vWPrkM7JZmv+YPBcG8xYsqsJlPij4bkuYgYg5peLvFzcS1bjsTXPS4irz4dZN 1llGi5Z1kx5oCq3MD8cGpE4D0MiyaZYjTXA4CiFQxZY03Bn4fVYbq4Q1+G9vQo0ZreqBSn W3S7QgRrhF7n3fOPYmPM9uSOpOcoE/jZvGa7/v8GzAjSLrP9+0Tut5qkL3nJ+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=RnPMCxb9; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=jpoiret.xyz header.s=dkim header.b=RnPMCxb9; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 324E63A301 X-Spam-Score: -3.13 X-Migadu-Scanner: scn1.migadu.com X-TUID: QfDzeBk+SE0Y * guix/channels.scm (channel-build-system): Add build system that turns a channel record into a package. * gnu/packages/package-management.scm (current-guix): Use channel-build-system. --- gnu/packages/package-management.scm | 45 +++++++++++++++++++++-------- guix/channels.scm | 23 +++++++++++++++ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index 35913e6153..fe906fd440 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -116,10 +116,14 @@ (define-module (gnu packages package-management) #:use-module (guix build-system trivial) ;; This will be loaded by build-self.scm, but guile-git is unavailable, so ;; lazily load instead. - #:autoload (guix channels) (channel-build-system guix-channel?) + #:autoload (guix channels) (channel-profile-build-system + channel-build-system + guix-channel?) + #:use-module (guix describe) #:use-module (guix download) #:use-module (guix gexp) #:use-module (guix git-download) + #:autoload (guix git) (git-checkout) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix utils) @@ -588,6 +592,18 @@ (define-public channel-source->profile-package (native-inputs '()) (propagated-inputs '())))) +(define-public channel->package + (lambda (channel) + "Return a package for the given CHANNEL." + (package + (inherit guix) + (version (string-append (package-version guix) "+")) + (build-system channel-build-system) + (arguments `(#:channel ,channel)) + (inputs '()) + (native-inputs '()) + (propagated-inputs '())))) + (define-public current-guix-package ;; This parameter allows callers to override the package that 'current-guix' ;; returns. This is useful when 'current-guix' cannot compute it by itself, @@ -595,22 +611,27 @@ (define-public current-guix-package (make-parameter #f)) (define-public current-guix - (let* ((repository-root (delay (canonicalize-path - (string-append (current-source-directory) - "/../..")))) - (select? (delay (or (git-predicate (force repository-root)) - source-file?)))) - (lambda () - "Return a package representing Guix built from the current source tree. -This works by adding the current source tree to the store (after filtering it -out) and returning a package that uses that as its 'source'." + (lambda () + "Return a package representing Guix built from the currently used one. +This works by either looking up profile or build metadata, and building from +the current Guix channel. If that metadata is missing, assume we are running +from a Git checkout, so add the current source tree to the store (after +filtering it out) and return a package that uses that as its 'source'." + (let* ((guix-channel (find guix-channel? (current-channels))) + (repository-root (canonicalize-path + (string-append (current-source-directory) + "/../.."))) + (select? (or (git-predicate repository-root) + source-file?))) (or (current-guix-package) + (and guix-channel + (channel->package guix-channel)) (package (inherit guix) (version (string-append (package-version guix) "+")) - (source (local-file (force repository-root) "guix-current" + (source (local-file repository-root "guix-current" #:recursive? #t - #:select? (force select?)))))))) + #:select? select?))))))) (define-public guix-icons (package diff --git a/guix/channels.scm b/guix/channels.scm index 01f63d9631..c930fd2ae7 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -94,6 +94,7 @@ (define-module (guix channels) channel-instances->derivation ensure-forward-channel-update + channel-build-system channel-profile-build-system profile-channels @@ -955,6 +956,28 @@ (define* (latest-channel-derivation #:optional (channels %default-channels) validate-pull))) (channel-instances->derivation instances))) +(define channel-build-system + ;; Build system used to "convert" a channel to a package. + (let* ((build (lambda* (name inputs + #:key channel system + #:allow-other-keys) + (mlet* %store-monad ((instance + ((store-lift latest-channel-instance) + channel + #:authenticate? #f + #:validate-pull (lambda (. rest) #t)))) + (build-from-source instance #:system system)))) + (lower (lambda* (name #:key system channel + #:allow-other-keys) + (bag + (name name) + (system system) + (build build) + (arguments `(#:channel ,channel)))))) + (build-system (name 'channel) + (description "Turn a channel into a package.") + (lower lower)))) + (define channel-profile-build-system ;; Build system used to "convert" a channel instance to a profile, in ;; package form. -- 2.34.0