diff mbox series

[bug#44191] gnu: Add kristall

Message ID 8736233h7h.fsf@guixSD.i-did-not-set--mail-host-address--so-tickle-me
State Accepted
Headers show
Series [bug#44191] gnu: Add kristall | expand

Checks

Context Check Description
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

Nicolò Balzarotti Oct. 24, 2020, 1:07 p.m. UTC
Hi guix!

This patch adds kristall, a qt browser for gemini and gopher.

There were some problems with the latest tagged version (V0.3), such as
directories that had to be created manually before install.  I preferred
to use the latest commit (as the author still does not know when a new
release will happen).  Let me know if it's fine.

Without the wrap-qt-program icons were missing.

guix lint reports no warnings.

Thanks!
Nicolò

Comments

Christopher Baines Oct. 25, 2020, 9:47 a.m. UTC | #1
Nicolò Balzarotti <anothersms@gmail.com> writes:

> Hi guix!
>
> This patch adds kristall, a qt browser for gemini and gopher.
>
> There were some problems with the latest tagged version (V0.3), such as
> directories that had to be created manually before install.  I preferred
> to use the latest commit (as the author still does not know when a new
> release will happen).  Let me know if it's fine.
>
> Without the wrap-qt-program icons were missing.
>
> guix lint reports no warnings.

Hey!

Thanks for the patch.

I've had a quick look, and spotted one thing. The Git repository
includes lib/BreezeStyleSheets and lib/cmark, which are both packaged
for Guix (I'm unsure about luis-l-gist). It would be good to look at
removing/not using the copied code from kristall and using the Guix
packages instead.

Does that make sense?

Thanks,

Chris
Nicolò Balzarotti Oct. 25, 2020, 4:47 p.m. UTC | #2
Hi Chris!

Thanks for the review.

I tried, but:
1. breeze is a different package from the ones in the repo (url is
https://github.com/Alexhuszagh/BreezeStyleSheets).  It does not seems to
be compiled, I can try to package it.
2. there are files in lib/cmark that are not present in the cmark
distribution (thei are .h files generated by their .h.in), so I cannot
extract our cmark source directly
   - I tried keeping those files, but build fails [[failed-build]].  Not sure if it's
   a patched version or if it's an older one.  But I can investigate
   probably
3. Should I do the same for fonts file? It depends on Noto (that we have
in the store) and on OpenMoji (I can package it)

Just for reference, I attached the current WIP package definition
([[current-package-definition]] which is getting complex.  Is there a
better way to achieve the "delete a folder, but keep some file"?)


Thanks!
Nicolò

#+name: failed-build
#+begin_example 
../src/renderers/markdownrenderer.cpp: In function ‘QString extractNodeText(const cmark_node&)’:
../src/renderers/markdownrenderer.cpp:102:48: error: ‘const cmark_node {aka const struct cmark_node}’ has no member named ‘data’
     return QString::fromUtf8((char const*)node.data, node.len);
                                                ^~~~
../src/renderers/markdownrenderer.cpp:102:59: error: ‘const cmark_node {aka const struct cmark_node}’ has no member named ‘len’
     return QString::fromUtf8((char const*)node.data, node.len);
                                                           ^~~
../src/renderers/markdownrenderer.cpp: In function ‘void renderNode(RenderState&, const cmark_node&, QTextCharFormat)’:
../src/renderers/markdownrenderer.cpp:262:67: error: invalid cast from type ‘const cmark_chunk’ to type ‘char*’
         QUrl absolute_url = QString::fromUtf8((char*)node.as.link.url);
#+end_example

#+name: current-package-definition
#+begin_src scheme
(define-public kristall
  ;; Fixes to the build system applied after the latest tag
  ;; Use tagged release when updating
  (let ((commit "b684f94f1af9a19c1a6fd70d72097a13b75e1ca6")
        (revision "1"))
    (package
      (name "kristall")
      (version (string-append "0.3-" revision "." (string-take commit 7)))
      (source
       (origin
         (method git-fetch)
         (uri (git-reference
               (url "https://github.com/MasterQ32/kristall")
               (commit commit)))
         (file-name (git-file-name name version))
         (sha256
          (base32
           "0kbn98pn8iplqkg7gxx4nysvgsn1621z95ynfr2f9jhsfsgz4r0z"))
         (modules '((guix build utils) (ice-9 match)))
         (snippet
          '(begin
             ;; /gnu/store/qy99msdihnam407659xdqdb4p99f0ava-font-google-noto-20171025/share/fonts/truetype/NotoColorEmoji.ttf
             ;; Remove bundled programs.
             ;; kristall requires some files in the cmark dir that are not
             ;; available in cmark sources.  Move it away from the directory
             ;; and then back in
             (with-directory-excursion "lib"
               (let ((files-to-keep '(("cmark/cmark.pri" "cmark.pri")
                                      ("cmark/src/config.h" "config.h")
                                      ("cmark/src/cmark.h" "cmark.h")
                                      ("cmark/src/cmark_export.h" "cmark_export.h")
                                      ("cmark/src/cmark_version.h" "cmark_version.h"))))
                 ;; Copy away files to keep
                 (map (match-lambda ((src . (dest)) (rename-file src dest)))
                      files-to-keep)
                 ;; Delete extra (bundled) files
                 (map (lambda (dir) (delete-file-recursively dir))
                      '("cmark" ;; "BreezeStyleSheets"
                        ))
                 ;; Put files to keep back in their original place
                 (mkdir-p "cmark/src")
                 (map (match-lambda ((dest . (src)) (rename-file src dest)))
                      files-to-keep)))
             ;; Remove bundled fonts
             (delete-file-recursively "fonts")
             #t))))
      (build-system gnu-build-system)
      (arguments
       `(#:modules ((guix build gnu-build-system)
                    (guix build qt-utils)
                    (guix build utils))
         #:imported-modules (,@%gnu-build-system-modules
                             (guix build qt-utils))
         #:make-flags
         (list (string-append "PREFIX=" %output))
         #:phases
         (modify-phases %standard-phases
           (delete 'configure)          ; no ./configure script
           (delete 'check)              ; no check target
           (add-after 'unpack 'replace-bundled-libs
             (lambda* (#:key inputs #:allow-other-keys)
               (let ((cmark (assoc-ref inputs "cmark-sources"))
                     ;; (breeze (assoc-ref inputs "breeze-sources"))
                     )
                 ;; (invoke "tar" "-xf" breeze "-C" "./lib/")
                 ;; (rename-file "./lib/breeze-5.19.5" "./lib/BreezeStyleSheets")
                 (invoke "tar" "-xf" cmark "-C" "./lib/cmark" "--strip-components" "1")
                 #t)))
           (add-before 'build 'set-program-version
             ;; runs git describe --tags by default
             (lambda _
               ;; configure.ac relies on ‘git --describe’ to get the version.
               ;; Patch it to just return the real version number directly.
               (substitute* "src/kristall.pro"
                 (("(KRISTALL_VERSION=).*" _ match)
                  (string-append match ,version "\n")))))
           (add-after 'install 'wrap-program
             (lambda* (#:key outputs #:allow-other-keys)
               (let ((out (assoc-ref outputs "out")))
                 (wrap-qt-program out "kristall"))
               #t)))))
      (inputs
       `(("breeze-sources" ,(package-source breeze-assets))
         ("cmark-sources" ,(package-source cmark))
         ("openssl" ,openssl)
         ("qtbase" ,qtbase)
         ("qtmultimedia" ,qtmultimedia)
         ("qtsvg" ,qtsvg)))
      (home-page "https://github.com/MasterQ32/kristall")
      (synopsis "Small-internet graphical client")
      (description "Graphical small-internet client with with many features
including multi-protocol support (gemini, http, https, gopher, finger),
bookmarks, TSL certificates management, outline generation, tabbed interface
and more.")
      (license license:gpl3))))
#+end_src

Christopher Baines <mail@cbaines.net> writes:

> Nicolò Balzarotti <anothersms@gmail.com> writes:
>
>> Hi guix!
>>
>> This patch adds kristall, a qt browser for gemini and gopher.
>>
>> There were some problems with the latest tagged version (V0.3), such as
>> directories that had to be created manually before install.  I preferred
>> to use the latest commit (as the author still does not know when a new
>> release will happen).  Let me know if it's fine.
>>
>> Without the wrap-qt-program icons were missing.
>>
>> guix lint reports no warnings.
>
> Hey!
>
> Thanks for the patch.
>
> I've had a quick look, and spotted one thing. The Git repository
> includes lib/BreezeStyleSheets and lib/cmark, which are both packaged
> for Guix (I'm unsure about luis-l-gist). It would be good to look at
> removing/not using the copied code from kristall and using the Guix
> packages instead.
>
> Does that make sense?
>
> Thanks,
>
> Chris
Christopher Baines Oct. 26, 2020, 4:43 p.m. UTC | #3
Nicolò Balzarotti <anothersms@gmail.com> writes:

> Hi Chris!
>
> Thanks for the review.
>
> I tried, but:
> 1. breeze is a different package from the ones in the repo (url is
> https://github.com/Alexhuszagh/BreezeStyleSheets).  It does not seems to
> be compiled, I can try to package it.
> 2. there are files in lib/cmark that are not present in the cmark
> distribution (thei are .h files generated by their .h.in), so I cannot
> extract our cmark source directly
>    - I tried keeping those files, but build fails [[failed-build]].  Not sure if it's
>    a patched version or if it's an older one.  But I can investigate
>    probably

I think you might be overcomplicating this. kristall shouldn't be trying
to build cmark, as it's a library, it should just be linking against
it. Therefore, you shouldn't need to keep the .h.in files.

Making kristall use cmark, rather than the copy in the kristall source
probably requires adapting/fixing src/kristall.pro.

It hopefully isn't that difficult, but I don't know what this .pro file
is, it also looks pretty odd in parts, especially the references to
/home/felix/... !

It doesn't look like the copy of cmark in the kristall source has been
modified much, which also raises the question of why there is a copy of
the cmark source inside kristall?
Nicolò Balzarotti Oct. 26, 2020, 6:12 p.m. UTC | #4
Just linking to it would be easier.  However, the file markdownrenderer
requires access to implementation details of the struct cmark_node
(it includes the file node.h, which is not installed by cmark, and fails
with: ../src/renderers/markdownrenderer.cpp:83:23: error: invalid use of incomplete type ‘const cmark_node {aka const struct cmark_node}’)

I replaced references such as `node.as.heading.level` to
`cmark_node_get_heading_level(node)` and so on.  I could compile it (by
also adding -I/gnu/store and -lcmark to the build process), and markdown
seems to be working (tested here
gemini://tilde.team/~supernova/blog/this-is-a-test-of-using-markdown.md).

I'm going to send a patch to the author, linking to this mail exchange.

I'll let you know.

Christopher Baines <mail@cbaines.net> writes:

> Nicolò Balzarotti <anothersms@gmail.com> writes:
>
>> Hi Chris!
>>
>> Thanks for the review.
>>
>> I tried, but:
>> 1. breeze is a different package from the ones in the repo (url is
>> https://github.com/Alexhuszagh/BreezeStyleSheets).  It does not seems to
>> be compiled, I can try to package it.
>> 2. there are files in lib/cmark that are not present in the cmark
>> distribution (thei are .h files generated by their .h.in), so I cannot
>> extract our cmark source directly
>>    - I tried keeping those files, but build fails [[failed-build]].  Not sure if it's
>>    a patched version or if it's an older one.  But I can investigate
>>    probably
>
> I think you might be overcomplicating this. kristall shouldn't be trying
> to build cmark, as it's a library, it should just be linking against
> it. Therefore, you shouldn't need to keep the .h.in files.
>
> Making kristall use cmark, rather than the copy in the kristall source
> probably requires adapting/fixing src/kristall.pro.
>
> It hopefully isn't that difficult, but I don't know what this .pro file
> is, it also looks pretty odd in parts, especially the references to
> /home/felix/... !
>
> It doesn't look like the copy of cmark in the kristall source has been
> modified much, which also raises the question of why there is a copy of
> the cmark source inside kristall?
diff mbox series

Patch

From c52c3ea7297c1b11cb3dd2ca7f5a12492e42defe Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Sat, 24 Oct 2020 15:00:30 +0200
Subject: [PATCH] gnu: Add kristall.

* gnu/packages/web-browsers.scm (kristall): New variable.
---
 gnu/packages/web-browsers.scm | 59 +++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/gnu/packages/web-browsers.scm b/gnu/packages/web-browsers.scm
index eb49a8fdea..f564f25f20 100644
--- a/gnu/packages/web-browsers.scm
+++ b/gnu/packages/web-browsers.scm
@@ -13,6 +13,7 @@ 
 ;;; Copyright © 2020 Raghav Gururajan <raghavgururajan@disroot.org>
 ;;; Copyright © 2020 B. Wilson <elaexuotee@wilsonb.com>
 ;;; Copyright © 2020 Michael Rohleder <mike@rohleder.de>
+;;; Copyright © 2020 Nicolò Balzarotti <nicolo@nixo.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -341,6 +342,64 @@  access.")
     (properties `((lint-hidden-cve . ("CVE-2016-9179"))))
     (license license:gpl2)))
 
+(define-public kristall
+  ;; Fixes to the build system applied after the latest tag
+  ;; Use tagged release when updating
+  (let ((commit "b684f94f1af9a19c1a6fd70d72097a13b75e1ca6")
+        (revision "1"))
+    (package
+      (name "kristall")
+      (version (string-append "0.3-" revision "." (string-take commit 7)))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/MasterQ32/kristall")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "0kbn98pn8iplqkg7gxx4nysvgsn1621z95ynfr2f9jhsfsgz4r0z"))
+         (modules '((guix build utils)))))
+      (build-system gnu-build-system)
+      (arguments
+       `(#:modules ((guix build gnu-build-system)
+                    (guix build qt-utils)
+                    (guix build utils))
+         #:imported-modules (,@%gnu-build-system-modules
+                             (guix build qt-utils))
+         #:make-flags
+         (list (string-append "PREFIX=" %output))
+         #:phases
+         (modify-phases %standard-phases
+           (delete 'configure)          ; no ./configure script
+           (delete 'check)              ; no check target
+           (add-before 'build 'set-program-version
+             ;; runs git describe --tags by default
+             (lambda _
+               ;; configure.ac relies on ‘git --describe’ to get the version.
+               ;; Patch it to just return the real version number directly.
+               (substitute* "src/kristall.pro"
+                 (("(KRISTALL_VERSION=).*" _ match)
+                  (string-append match ,version "\n")))))
+           (add-after 'install 'wrap-program
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 (wrap-qt-program out "kristall"))
+               #t)))))
+      (inputs
+       `(("openssl" ,openssl)
+         ("qtbase" ,qtbase)
+         ("qtmultimedia" ,qtmultimedia)
+         ("qtsvg" ,qtsvg)))
+      (home-page "https://github.com/MasterQ32/kristall")
+      (synopsis "Small-internet graphical client")
+      (description "Graphical small-internet client with with many features
+including multi-protocol support (gemini, http, https, gopher, finger),
+bookmarks, TSL certificates management, outline generation, tabbed interface
+and more.")
+      (license license:gpl3))))
+
 (define-public qutebrowser
   (package
     (name "qutebrowser")
-- 
2.28.0