From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 kEl7D7K+mGPJMgEAbAwnHQ (envelope-from ) for ; Tue, 13 Dec 2022 19:04:34 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cOl9D7K+mGPECQEAauVa8A (envelope-from ) for ; Tue, 13 Dec 2022 19:04:34 +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 C1D28E01F for ; Tue, 13 Dec 2022 19:04:33 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p59d7-000777-13; Tue, 13 Dec 2022 13:03:49 -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 1p59cO-00071R-32 for guix-patches@gnu.org; Tue, 13 Dec 2022 13:03:04 -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 1p59cN-0000lO-Qz for guix-patches@gnu.org; Tue, 13 Dec 2022 13:03:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p59cN-0003Gu-MV for guix-patches@gnu.org; Tue, 13 Dec 2022 13:03:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60029] [PATCH 3/4] guix: add vim-build-system Resent-From: Jonathan Scoresby Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 13 Dec 2022 18:03: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.167095456112528 (code B ref 60029); Tue, 13 Dec 2022 18:03:03 +0000 Received: (at 60029) by debbugs.gnu.org; 13 Dec 2022 18:02:41 +0000 Received: from localhost ([127.0.0.1]:33706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p59c0-0003Fu-4E for submit@debbugs.gnu.org; Tue, 13 Dec 2022 13:02:40 -0500 Received: from mout-p-102.mailbox.org ([80.241.56.152]:41722) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p50nJ-0001nm-Dt for 60029@debbugs.gnu.org; Tue, 13 Dec 2022 03:37:46 -0500 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::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 4NWX1W6dnVz9sTF; Tue, 13 Dec 2022 09:37:35 +0100 (CET) From: Jonathan Scoresby Date: Tue, 13 Dec 2022 01:34:19 -0700 Message-Id: <96764b0038f17f7dd67d800a0143cdbbfb727ddb.1670891520.git.me@jonscoresby.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4NWX1W6dnVz9sTF X-Mailman-Approved-At: Tue, 13 Dec 2022 13:02:37 -0500 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=1670954673; 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=MSz/O5z4i4ocjQPDRQbnzfBUXlyEZ2x1y6WkH+HPqGLy27wfznvjvYP76i09Lueh+h4Sux HSv6mnZv6/pcJCeDDzREc3HEYefo1m1v1oGgZKnnonXFnaO6rJu8vOWpWPJW+XHZ5eQ8YL RM52rzLDQ4CKp1UecxC+v91SVOJjolJpVFBym6Df7mx5Etngmqi0sj7/Wd3UE35EhrbSDH yz6EP4uMDUX05IoKLBvsTGDsQRjrAbg/MWBER4wj23xFn4zkwR81yiFbXc/vc0ghY3Y3y7 OVJ75dfMcJWUuCV/omLl/VJ3Ld3bhdXemnzz7fQxjfvrX9dV1ENLM37h953oZA== 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=1670954673; a=rsa-sha256; cv=none; b=Zp7iH8++iw7LPqgWi99RFMVSae8pevBLvTX/dRAISBSb8DhvAgdNzJLRjwxpTSgmd3pJOi q5jISzvtE99CSQtuDoFuL9SJHbEaFKVQ8mJ0PnLOBgOzLtlD2mHEuSW+Ds1AL4hQe23rUD w2uLzaSCJma9ZaDx2ZqmJwzlzYvJJSXwJewJHNz1iNTfBhOHW1W8UPPtqo81DZQh4mym7a tWbP1jFGePZnTmFbKIwlIWmZ2FEWf3g71rSEQnLQydxZ5zzRPQpE0zMh4p6iME5lkrJ9YT tY7n6bxviEbCsbeLvfDLSgnpM5os44lJjQpsKuzwpJGsia9AkGvejavyhkLCqA== X-Migadu-Spam-Score: -1.37 X-Spam-Score: -1.37 X-Migadu-Queue-Id: C1D28E01F 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: obKKZ9+bXjWT --- 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