From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 0LCXMlo6mmOteQAAbAwnHQ (envelope-from ) for ; Wed, 14 Dec 2022 22:04:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 6NWrMVo6mmPPKAAAG6o9tA (envelope-from ) for ; Wed, 14 Dec 2022 22:04:26 +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 644299120 for ; Wed, 14 Dec 2022 22:04:26 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Yv7-0001FD-Te; Wed, 14 Dec 2022 16:04:05 -0500 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 1p5Yv5-0001Ea-K8 for guix-patches@gnu.org; Wed, 14 Dec 2022 16:04:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Yv5-00009R-9C for guix-patches@gnu.org; Wed, 14 Dec 2022 16:04:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5Yv5-0006jA-37 for guix-patches@gnu.org; Wed, 14 Dec 2022 16:04:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60029] [PATCH v2 3/4] guix: add vim-build-system Resent-From: Jonathan Scoresby Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 14 Dec 2022 21:04:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60029 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60029@debbugs.gnu.org Cc: Jonathan Scoresby Received: via spool by 60029-submit@debbugs.gnu.org id=B60029.167105183225840 (code B ref 60029); Wed, 14 Dec 2022 21:04:03 +0000 Received: (at 60029) by debbugs.gnu.org; 14 Dec 2022 21:03:52 +0000 Received: from localhost ([127.0.0.1]:41848 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5Yut-0006ii-Mp for submit@debbugs.gnu.org; Wed, 14 Dec 2022 16:03:52 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]:58810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5Yur-0006iP-CS for 60029@debbugs.gnu.org; Wed, 14 Dec 2022 16:03:50 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4NXSWv4cYGz9sT9; Wed, 14 Dec 2022 22:03:39 +0100 (CET) From: Jonathan Scoresby Date: Wed, 14 Dec 2022 14:02:02 -0700 Message-Id: <651da6730a8b03b7f5dae5fd37f61ffd65ad498a.1671051720.git.me@jonscoresby.com> In-Reply-To: <57f2e77fc975bf00d1222729b0e41aef5c8a00a0.1671051720.git.me@jonscoresby.com> References: <57f2e77fc975bf00d1222729b0e41aef5c8a00a0.1671051720.git.me@jonscoresby.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671051866; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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; bh=3MFWaw7/do3+ndCI1tcOJD6n4MLvqd/XV8kEt+L4S/A=; b=cLM0PPDlCGcFSLDgz15J5LUg7ult5TB5+P3+LQaqsPrY3DS8KGfyDoiBBKyO4SIWRFOnUp 1VY7DA9GDwrkfKHSnC0NEWH/5UvQ8x81nezF0n04mxOOqtD0vbub9oIVqmWI48cSoGDOoB Xlbg4WWlUJw1OiKbf3YGtVlwfn9LnueiUKyWFoF1ppzsz4+RdqAFtJOMbF8cwFkc8eDXdu +vpuBflDv5dvQkOfQVHMvcA3RGP1B+pCc+sZYlT+Q8LhiWxcC1bs0SQ4YPxGOlYzqwnEGI JkUW1U4ejXKUoBEBt8pCggOCTe7ncgPTbL+VY4Gqq2hP7zGKIrvbhlzwEPj3Ww== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671051866; a=rsa-sha256; cv=none; b=rtmwIUhIvJ5Ky6p9sGc8Rxo6qgJ3iSvdYSlgnWfutpXJzf5zZgywiC92XIGP3cOShW1PAK RHEjtBd2JrYjWbpglfv3Pdwvf4FYkxYhGEuTm9QqPYnnwBhML+wtXw2WAcmgJ/WkzEWSje cToqC09sAyY46X6c7HMBIP4o/gSNlA7uICeah/R1qyBOq1Umv8fjg9rRfAEssELX0GqDnT VO6xLQl2UZKpOGvCIBw5ZzsqbqPHyXARoSNzBW/MS6SAyQosHc06YVHdYhf8RJ/EqQOYw5 DFSr0dBVyD+6qa0/8IUAl89s79CMtlH+9oMIA2MAoRw5rvZwRGmwnyL3gn3kcw== X-Migadu-Spam-Score: -3.27 X-Spam-Score: -3.27 X-Migadu-Queue-Id: 644299120 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=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"; dmarc=none X-TUID: c4BFydb2SFPr --- guix/build-system/vim.scm | 160 ++++++++++++++++++++++++++++++++ guix/build/vim-build-system.scm | 137 +++++++++++++++++++++++++++ 2 files changed, 297 insertions(+) create mode 100644 guix/build-system/vim.scm create mode 100644 guix/build/vim-build-system.scm diff --git a/guix/build-system/vim.scm b/guix/build-system/vim.scm new file mode 100644 index 0000000000..4b74c24e10 --- /dev/null +++ b/guix/build-system/vim.scm @@ -0,0 +1,160 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 Jonathan Scoresby +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build-system vim) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix gexp) + #:use-module (guix monads) + #:use-module (guix packages) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system copy) + #:use-module (guix build-system gnu) + #:export (%vim-build-system-modules vim-build vim-build-system)) + +;; Commentary: +;; +;; Standard package installer for vim and neovim plugins. +;; This is implemented as an extension of `copy-build-system' +;; and takes advantage of vim and neovim's built-in package manager. +;; It extends the installation procedure from the copy-build-system +;; to put files in the correct place and then generates help tags. +;; +;; Code: + +(define %vim-build-system-modules + ;; Build-side modules imported by default. + `((guix build vim-build-system) + ,@%copy-build-system-modules)) + +(define (default-vim) + "Return the default Vim package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((vim (resolve-interface '(gnu packages vim)))) + (module-ref vim + 'vim))) + +(define (default-neovim) + "Return the default Neovim package." + (let ((vim (resolve-interface '(gnu packages vim)))) + (module-ref vim + 'neovim))) + +(define* (lower name + #:key source + inputs + native-inputs + outputs + system + target + (vim? #f) + (neovim? #f) + (vim (default-vim)) + (neovim (default-neovim)) + #:allow-other-keys #:rest arguments) + "Return a bag for NAME." + (let* ((private-keywords '(#:target #:vim #:neovim #:inputs #:native-inputs)) + (vim? (or (= 0 + (string-contains name "vim")) vim?)) + (neovim? (or (not (not (or (string-contains name "neovim") + (member "neovim" outputs)))) neovim?)) + (vim-inputs (append (if vim? + `(("vim" ,vim)) + '()) + (if neovim? + `(("neovim" ,neovim)) + '()))) + (vim-arguments (append arguments + `(#:vim? ,vim? + #:neovim? ,neovim?)))) + (bag (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (build-inputs `(,@vim-inputs ,@native-inputs)) + (outputs outputs) + (build vim-build) + (arguments (strip-keyword-arguments private-keywords vim-arguments))))) + +(define* (vim-build name + inputs + #:key guile + source + (vim? #f) + (neovim? #f) + (mode "start") + (install-plan ''()) + (phases '(@ (guix build vim-build-system) %standard-phases)) + (outputs '("out")) + (search-paths '()) + (system (%current-system)) + (imported-modules %vim-build-system-modules) + (modules '((guix build vim-build-system) + (guix build utils)))) + + (define build + (with-imported-modules imported-modules + #~(begin + (use-modules #$@modules) + #$(with-build-variables inputs outputs + #~(vim-build #:name #$name + #:vim? #$vim? + #:neovim? #$neovim? + #:mode #$mode + #:install-plan #$(if + (pair? + install-plan) + (sexp->gexp + install-plan) + install-plan) + #:source #+source + #:system #$system + #:phases #$(if (pair? + phases) + (sexp->gexp + phases) + phases) + #:outputs %outputs + #:search-paths '#$(sexp->gexp + (map + search-path-specification->sexp + search-paths)) + #:inputs + %build-inputs))))) + + (mlet %store-monad + ((guile (package->derivation (or guile + (default-guile)) system + #:graft? #f))) + (gexp->derivation name + build + #:system system + #:target #f + #:guile-for-build guile))) + +(define vim-build-system + (build-system (name 'vim) + (description "The standard Vim build system") + (lower lower))) + +;;; vim.scm ends here diff --git a/guix/build/vim-build-system.scm b/guix/build/vim-build-system.scm new file mode 100644 index 0000000000..38d82c416b --- /dev/null +++ b/guix/build/vim-build-system.scm @@ -0,0 +1,137 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 Jonathan Scoresby +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build vim-build-system) + #:use-module ((guix build copy-build-system) + #:prefix copy:) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:use-module (ice-9 ftw) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (%standard-phases vim-build)) + +;; Commentary: +;; +;; System for installing vim and neovim plugins. It downloads +;; the source and copies the appropriate files to vim and nvim +;; packpaths. It then generates helptags. +;; +;; Code: + +(define copy:install + (assoc-ref copy:%standard-phases + 'install)) + +(define vim-path + "/share/vim/vimfiles/pack/guix/") +(define nvim-path + "/share/nvim/site/pack/guix/") + +(define* (install #:key name + install-plan + neovim? + vim? + mode + outputs + #:allow-other-keys) + + (let* ((include-regexp '(".*\\/.*\\/.*")) + (exclude-regexp '("scripts/.*" "tests?/.*" ".*\\/\\..*")) + (vim-install (if vim? + `(("." ,(string-append vim-path mode "/" name "/") + #:include-regexp ,include-regexp + #:exclude-regexp ,exclude-regexp)) + '())) + (neovim-outputs (if vim? + `(("." ,(string-append nvim-path mode "/" name + "/") + #:include-regexp ,include-regexp + #:exclude-regexp ,exclude-regexp + #:output "neovim")) + `(("." ,(string-append nvim-path mode "/" name + "/") + #:include-regexp ,include-regexp + #:exclude-regexp ,exclude-regexp)))) + (neovim-install (if neovim? neovim-outputs + '()))) + (copy:install #:outputs outputs + #:install-plan (append vim-install neovim-install + install-plan)))) + +(define* (generate-helptags #:key name + neovim? + vim? + mode + outputs + #:allow-other-keys) + + (define (vim-generate output) + (invoke "vim" "--clean" "-en" "--cmd" + (string-append "helptags " + output + vim-path + mode + "/" + name + "/doc | q"))) + + (define (neovim-generate output) + (invoke "nvim" + "--clean" + "--headless" + "-en" + "--cmd" + (string-append "helptags " + output + nvim-path + mode + "/" + name + "/doc | q"))) + + (when (scandir "./doc") + (let ((out (assoc-ref outputs "out")) + (neovim (assoc-ref outputs "neovim"))) + (if vim? + (begin + (vim-generate out) + (if neovim? + (neovim-generate neovim))) + (neovim-generate out))))) + +(define %standard-phases + ;; Everything is as with the Copy Build System except for + ;; the addition of the generate-helptags phase and a few + ;; custom actions are added to the install phase + (modify-phases copy:%standard-phases + (replace 'install + install) + (add-after 'install 'generate-helptags + generate-helptags))) + +(define* (vim-build #:key inputs + (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given package, applying all of PHASES in order." + (apply copy:copy-build + #:inputs inputs + #:phases phases + args)) + +;;; vim-build-system.scm ends here -- 2.38.1