From 57b2f9e6af20606e302fc4040515d7a92bde73fc Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Fri, 30 Dec 2016 02:15:59 +1100 Subject: [PATCH] gnu: Add kakoune To: guix-devel@gnu.org * gnu/packages/patches/kakoune-fix-bash-path.patch: New file. * gnu/packages/patches/kakoune-leave-manpages-uncompressed.patch: New file. * gnu/local.mk (dist_patch_DATA): Register patches. * gnu/packages/text-editors.scm (kakoune): New variable. --- gnu/local.mk | 2 + gnu/packages/patches/kakoune-fix-bash-path.patch | 34 ++++++++++ .../kakoune-leave-manpages-uncompressed.patch | 65 +++++++++++++++++++ gnu/packages/text-editors.scm | 73 +++++++++++++++++++++- 4 files changed, 173 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/kakoune-fix-bash-path.patch create mode 100644 gnu/packages/patches/kakoune-leave-manpages-uncompressed.patch diff --git a/gnu/local.mk b/gnu/local.mk index 106adb235..5517be2de 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -640,6 +640,8 @@ dist_patch_DATA = \ %D%/packages/patches/isl-0.11.1-aarch64-support.patch \ %D%/packages/patches/jbig2dec-ignore-testtest.patch \ %D%/packages/patches/jq-CVE-2015-8863.patch \ + %D%/packages/patches/kakoune-fix-bash-path.patch \ + %D%/packages/patches/kakoune-leave-manpages-uncompressed.patch \ %D%/packages/patches/kdbusaddons-kinit-file-name.patch \ %D%/packages/patches/khmer-use-libraries.patch \ %D%/packages/patches/kmod-module-directory.patch \ diff --git a/gnu/packages/patches/kakoune-fix-bash-path.patch b/gnu/packages/patches/kakoune-fix-bash-path.patch new file mode 100644 index 000000000..35b076d57 --- /dev/null +++ b/gnu/packages/patches/kakoune-fix-bash-path.patch @@ -0,0 +1,34 @@ +--- a/src/shell_manager.cc ++++ b/src/shell_manager.cc +@@ -22,30 +22,7 @@ + + ShellManager::ShellManager() + { +- // Get a guaranteed to be POSIX shell binary +- { +- auto size = confstr(_CS_PATH, 0, 0); +- String path; path.resize(size-1, 0); +- confstr(_CS_PATH, path.data(), size); +- for (auto dir : StringView{path} | split(':')) +- { +- String candidate = format("{}/sh", dir); +- struct stat st; +- if (stat(candidate.c_str(), &st)) +- continue; +- +- bool executable = (st.st_mode & S_IXUSR) +- | (st.st_mode & S_IXGRP) +- | (st.st_mode & S_IXOTH); +- if (S_ISREG(st.st_mode) and executable) +- { +- m_shell = std::move(candidate); +- break; +- } +- } +- if (m_shell.empty()) +- throw runtime_error{format("unable to find a posix shell in {}", path)}; +- } ++ m_shell = "__BASH_PATH__/bin/sh"; + + // Add Kakoune binary location to the path to guarantee that %sh{ ... } + // have access to the kak command regardless of if the user installed it diff --git a/gnu/packages/patches/kakoune-leave-manpages-uncompressed.patch b/gnu/packages/patches/kakoune-leave-manpages-uncompressed.patch new file mode 100644 index 000000000..f7118c309 --- /dev/null +++ b/gnu/packages/patches/kakoune-leave-manpages-uncompressed.patch @@ -0,0 +1,65 @@ +--- a/src/Makefile ++++ b/src/Makefile +@@ -22,7 +22,7 @@ + objects := $(addprefix ., $(sources:.cc=$(suffix).o)) + deps := $(addprefix ., $(sources:.cc=$(suffix).d)) + docs := $(wildcard ../doc/manpages/*.asciidoc) +-mandocs := $(docs:.asciidoc=.gz) ++mandocs := $(docs:.asciidoc=.1) + + PREFIX ?= /usr/local + DESTDIR ?= # root dir +@@ -76,19 +76,17 @@ + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $< + + # Generate the man page +-../doc/kak.1.gz: ../doc/kak.1.txt ++../doc/kak.1: ../doc/kak.1.txt + a2x --no-xmllint -f manpage $< +- gzip -f $(basename $<) + + # Generate the editor's documentation pages + # Since `a2x` won't generate man pages if some sections are missing (which we don't need), +-# we generate the pages, patch them and then compress them +-../doc/manpages/%.gz: ../doc/manpages/%.asciidoc ++# we generate the pages and patch them ++../doc/manpages/%.1: ../doc/manpages/%.asciidoc + a2x --no-xmllint -f manpage $< + sed -i -r -e "s,^\.TH .+,.TH KAKOUNE 1 \"\" \"\" \"$(basename $(notdir $<))\"," \ +- -e "/^\.SH \"NAME\"/{N;d;}" $(@:.gz=.1) +- gzip -f $(@:.gz=.1) +- mv -f $(@:.gz=.1.gz) $@ ++ -e "/^\.SH \"NAME\"/{N;d;}" $@ ++ + + check: test + test: +@@ -97,7 +95,7 @@ + TAGS: tags + tags: + ctags -R +-man: ../doc/kak.1.gz ++man: ../doc/kak.1 + doc: $(mandocs) + + clean: +@@ -124,8 +122,8 @@ + [ -e $(sharedir)/autoload ] || ln -s rc $(sharedir)/autoload + install -m 0644 ../colors/* $(sharedir)/colors + install -m 0644 ../README.asciidoc $(docdir) +- install -m 0644 ../doc/manpages/*.gz $(docdir)/manpages +- install -m 0644 ../doc/kak.1.gz $(mandir) ++ install -m 0644 ../doc/manpages/*.1 $(docdir)/manpages ++ install -m 0644 ../doc/kak.1 $(mandir) + + install-strip: install + strip -s $(bindir)/kak +@@ -134,7 +132,7 @@ + rm -rf $(bindir)/kak \ + $(sharedir) \ + $(docdir) \ +- $(mandir)/kak.1.gz ++ $(mandir)/kak.1 + + .PHONY: check TAGS clean distclean installdirs install install-strip uninstall + .PHONY: tags test man doc diff --git a/gnu/packages/text-editors.scm b/gnu/packages/text-editors.scm index 4e2324dbe..c3981948e 100644 --- a/gnu/packages/text-editors.scm +++ b/gnu/packages/text-editors.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 José Miguel Sánchez García +;;; Copyright © 2016 Carlo Zancanaro ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,13 +20,20 @@ (define-module (gnu packages text-editors) #:use-module (guix packages) #:use-module (guix download) + #:use-module (guix git-download) #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module ((guix licenses) #:prefix license:) #:use-module (gnu packages) #:use-module (gnu packages lua) #:use-module (gnu packages ncurses) - #:use-module (gnu packages terminals)) + #:use-module (gnu packages terminals) + #:use-module (gnu packages gcc) + #:use-module (gnu packages bash) + #:use-module (gnu packages documentation) + #:use-module (gnu packages boost) + #:use-module (gnu packages ruby) + #:use-module (gnu packages xml)) (define-public vis (package @@ -75,3 +83,66 @@ based command language.") (license (list license:isc ; Main distribution. license:public-domain ; map.[ch] license:expat)))) ; lexers and libutf.[ch] + +(define-public kakoune + (let ((commit "4f986776423f5cd5fd80a16735f873ae23c10da2")) + (package + (name "kakoune") + (version (string-append "0.0.1-" (string-take commit 7))) + (source + (origin + (file-name (string-append "kakoune-" version)) + (method git-fetch) + (uri (git-reference + (url "https://github.com/mawww/kakoune.git") + (commit commit))) + (sha256 + (base32 + "1nwkz18f73xcygayj42ijd70afzvwpasnqj84x4pdxgf4s349ipy")) + (patches + (search-patches + "kakoune-fix-bash-path.patch" + "kakoune-leave-manpages-uncompressed.patch")))) + (build-system gnu-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-before 'configure 'patch-bash-path + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "src/shell_manager.cc" + (("__BASH_PATH__") + (assoc-ref inputs "bash"))))) + ;; Kakoune doesn't have a configure script, but it still + ;; requires us to do some setup/configuration. + (replace 'configure + (lambda* (#:key outputs #:allow-other-keys) + ;; Make has to be run in the src/ directory, so let's + ;; move there now. + (chdir "src") + ;; Boost is compiled with the older ABI, so we can't use + ;; the new ABI if we want to link againt it. + (setenv "CPPFLAGS" "-D_GLIBCXX_USE_CXX11_ABI=0") + (setenv "PREFIX" (assoc-ref outputs "out")))) + (add-before 'check 'fix-test-permissions + (lambda* _ + ;; The tests fail if they can't write over files in the + ;; test directory, so make sure we can write everywhere + ;; we might possibly need to. + (system* "chmod" "-R" "u+w" "../test")))))) + (native-inputs `(("gcc" ,gcc-5) + ("libxslt" ,libxslt) + ("asciidoc" ,asciidoc) + ("ruby" ,ruby))) + (inputs `(("gcc:lib" ,gcc-5 "lib") + ("bash" ,bash) + ("ncurses" ,ncurses) + ("boost" ,boost))) + (synopsis "Vim-inspired code editor") + (description + "Kakoune is a code editor heavily inspired by Vim, as such most of its +commands are similar to Vi's ones, and it shares Vi's \"keystrokes as a text +editing language\" model. Kakoune has a strong focus on interactivity, most +commands provide immediate and incremental results, while still being +competitive (as in keystroke count) with Vim.") + (home-page "http://kakoune.org/") + (license license:unlicense)))) -- 2.11.0