From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 14 04:29:36 2022 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== From: Josselin Poiret To: =?UTF-8?q?Ludovic=20Court=C3=A8s?= , Mathieu Othacehe Subject: [WIP PATCH 3/4] gnu: current-guix: Support when running outside a checkout. 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 Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / X-Spam-Score: 2.1 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * 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/package [...] Content analysis details: (2.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 53210 Cc: Josselin Poiret , 53210@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.1 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * 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/package [...] Content analysis details: (1.1 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 1.6 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: jpoiret.xyz (xyz)] 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * 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