From patchwork Tue Jul 9 19:26:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janneke Nieuwenhuizen X-Patchwork-Id: 14552 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 106D2171E8; Tue, 9 Jul 2019 20:27:26 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 9E1BB171E6 for ; Tue, 9 Jul 2019 20:27:25 +0100 (BST) Received: from localhost ([::1]:53854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvlt-0007kG-As for patchwork@mira.cbaines.net; Tue, 09 Jul 2019 15:27:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36576) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvlc-0007hx-IX for guix-patches@gnu.org; Tue, 09 Jul 2019 15:27:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkvlX-0006tc-1T for guix-patches@gnu.org; Tue, 09 Jul 2019 15:27:06 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53708) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkvlW-0006se-2c for guix-patches@gnu.org; Tue, 09 Jul 2019 15:27:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hkvlV-0004Yl-Ur for guix-patches@gnu.org; Tue, 09 Jul 2019 15:27:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#36563] [PATCH] guix: Add directory to channel. Resent-From: Jan Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 09 Jul 2019 19:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36563 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 36563@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.156270039317489 (code B ref -1); Tue, 09 Jul 2019 19:27:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 Jul 2019 19:26:33 +0000 Received: from localhost ([127.0.0.1]:34296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hkvky-0004Xw-OO for submit@debbugs.gnu.org; Tue, 09 Jul 2019 15:26:33 -0400 Received: from lists.gnu.org ([209.51.188.17]:39050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hkvkv-0004Xn-Ms for submit@debbugs.gnu.org; Tue, 09 Jul 2019 15:26:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36204) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkvkt-0007Vt-Tc for guix-patches@gnu.org; Tue, 09 Jul 2019 15:26:25 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hkvkn-0006QG-Og; Tue, 09 Jul 2019 15:26:19 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=39842 helo=dundal.peder.onsbrabantnet.nl) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hkvka-00062d-Fs; Tue, 09 Jul 2019 15:26:07 -0400 From: Jan Nieuwenhuizen Date: Tue, 09 Jul 2019 21:26:00 +0200 Message-ID: <878st7dn7b.fsf@gnu.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches Hi! I commonly use a "guix/" subdirectory in upstream that contains updated or modified packages. The toplevel `guix.scm' then uses those package definitions. It would be nice if I could use that "guix/" subdirectory directly in a channel. This means a channel definition should look in a subdirectory only: often an upstream source archive contains .scm files that do not compile (guix.scm, build-aux/*.scm, etc.) WDYT? Greetings, janneke From cf85280211ff0060b5283dc5a53cb15ee09a7998 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 9 Jul 2019 21:01:11 +0200 Subject: [PATCH] guix: Add directory to channel. Typical use (cons* (channel (name 'mes) (url "https://git.savannah.gnu.org/git/mes.git") (directory "guix") (branch "wip")) %default-channels) * guix/channels.scm (): Add directory. (read-channel-metadata): Fill directory slot. (checkout->channel-instance): Add #:directory parameter. Update callers. (standard-module-derivation): Add directory parameter. Update callers. (build-channel-instance): Provide directory argument. --- guix/channels.scm | 58 ++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/guix/channels.scm b/guix/channels.scm index e6bb9b891b..bd64906832 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2019 Ludovic Courtès ;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -50,6 +51,7 @@ channel-branch channel-commit channel-location + channel-directory %default-channels guix-channel? @@ -86,7 +88,8 @@ (branch channel-branch (default "master")) (commit channel-commit (default #f)) (location channel-location - (default (current-source-location)) (innate))) + (default (current-source-location)) (innate)) + (directory channel-directory (default #f))) (define %default-channels ;; Default list of channels. @@ -141,7 +144,8 @@ file." (name name) (branch branch) (url url) - (commit (get 'commit)))))) + (commit (get 'commit)) + (directory (get 'directory)))))) dependencies)))))) (define (channel-instance-dependencies instance) @@ -205,13 +209,16 @@ of previously processed channels." (define* (checkout->channel-instance checkout #:key commit - (url checkout) (name 'guix)) + (url checkout) + (name 'guix) + directory) "Return a channel instance for CHECKOUT, which is assumed to be a checkout of COMMIT at URL. Use NAME as the channel name." (let* ((commit (or commit (make-string 40 #\0))) (channel (channel (name name) (commit commit) - (url url)))) + (url url) + (directory directory)))) (channel-instance channel commit checkout))) (define %self-build-file @@ -225,11 +232,12 @@ of COMMIT at URL. Use NAME as the channel name." ;; place a set of compiled Guile modules in ~/.config/guix/latest. 1) -(define (standard-module-derivation name source core dependencies) +(define (standard-module-derivation name source directory core dependencies) "Return a derivation that builds with CORE, a Guix instance, the Scheme -modules in SOURCE and that depend on DEPENDENCIES, a list of lowerable -objects. The assumption is that SOURCE contains package modules to be added -to '%package-module-path'." +modules in SOURCE or if DIRECTORY in SOURCE/DIRECTORY and that depend on +DEPENDENCIES, a list of lowerable objects. The assumption is that SOURCE or +SOURCE/DIRECTORY contains package modules to be added to +'%package-module-path'." ;; FIXME: We should load, say SOURCE/.guix-channel.scm, which would allow ;; channel publishers to specify things such as the sub-directory where .scm ;; files live, files to exclude from the channel, preferred substitute URLs, @@ -253,20 +261,27 @@ to '%package-module-path'." (string-append #$output "/share/guile/site/" (effective-version))) - (compile-files #$source go - (find-files #$source "\\.scm$")) - (mkdir-p (dirname scm)) - (symlink #$source scm) + (let* ((subdir (if #$directory + (string-append "/" #$directory) + "")) + (dir (string-append #$source subdir))) + (compile-files dir go + (warn 'files (find-files dir "\\.scm$"))) + (mkdir-p (dirname scm)) + (symlink (string-append #$source subdir) scm)) + scm))) (gexp->derivation-in-inferior name build core)) (define* (build-from-source name source #:key core verbose? commit - (dependencies '())) + (dependencies '()) + directory) "Return a derivation to build Guix from SOURCE, using the self-build script contained therein; use COMMIT as the version string. When CORE is true, build -package modules under SOURCE using CORE, an instance of Guix." +package modules under SOURCE or if DIRECTORY under SOURCE/DIRECTORY using +CORE, an instance of Guix." ;; Running the self-build script makes it easier to update the build ;; procedure: the self-build script of the Guix-to-be-installed contains the ;; right dependencies, build procedure, etc., which the Guix-in-use may not @@ -293,19 +308,20 @@ package modules under SOURCE using CORE, an instance of Guix." #:pull-version %pull-version)) ;; Build a set of modules that extend Guix using the standard method. - (standard-module-derivation name source core dependencies))) + (standard-module-derivation name source directory core dependencies))) (define* (build-channel-instance instance #:optional core (dependencies '())) "Return, as a monadic value, the derivation for INSTANCE, a channel instance. DEPENDENCIES is a list of extensions providing Guile modules that INSTANCE depends on." - (build-from-source (symbol->string - (channel-name (channel-instance-channel instance))) - (channel-instance-checkout instance) - #:commit (channel-instance-commit instance) - #:core core - #:dependencies dependencies)) + (let ((channel (channel-instance-channel instance))) + (build-from-source (symbol->string (channel-name channel)) + (channel-instance-checkout instance) + #:commit (channel-instance-commit instance) + #:core core + #:dependencies dependencies + #:directory (channel-directory channel)))) (define (resolve-dependencies instances) "Return a procedure that, given one of the elements of INSTANCES, returns -- 2.21.0