Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions pkgs/applications/misc/rtfm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,51 @@
, desktopToDarwinBundle
, webkitgtk_6_0
, sqlite
, gi-crystal
, libadwaita
, gtk4
, pango
, substituteAll
}:
let
gtk4' = gtk4.override { x11Support = true; };
pango' = pango.override { withIntrospection = true; };
in
crystal.buildCrystalPackage rec {
pname = "rtfm";
version = "0.2.4";
version = "0.4.1";

src = fetchFromGitHub {
owner = "hugopl";
repo = "rtfm";
rev = "v${version}";
name = "rtfm";
hash = "sha256-IfI7jYM1bsrCq2NiANv/SWkCjPyT/HYUofJMUYy0Sbk=";
hash = "sha256-cloaGlHjtwrjuPGzAG55B58w307R+TO+MixAWTw2ags=";
};

patches = [
# 1) fixed gi-crystal binding generator command
# 2) removed `-v` arg to `cp` command to prevent build failure due to stdout buffer overflow
# 2) fixed docset generator command
# 3) added commands to build gschemas and update icon-cache
./patches/make.patch

# fixed docset path and gi libs directory names
./patches/friendly-docs-path.patch

(substituteAll {
src = ./make.patch;
inherit crystal;
})
# added chmod +w for copied docs to prevent error:
# `Error opening file with mode 'wb': '.../style.css': Permission denied`
./patches/enable-write-permissions.patch
./enable-write-permissions.patch
];

postPatch = ''
substituteInPlace Makefile \
--replace "crystal run src/create_crystal_docset.cr" "crystal src/create_crystal_docset.cr ${crystal}/share/doc/crystal/api/" \
--replace "crystal run src/create_gtk_docset.cr" "crystal src/create_gtk_docset.cr gtk-doc/"
substituteInPlace src/doc2dash/create_gtk_docset.cr \
--replace-fail 'basedir = Path.new("/usr/share/doc")' 'basedir = Path.new(ARGV[0]? || "gtk-docs")'
'';

shardsFile = ./shards.nix;
copyShardDeps = true;

nativeBuildInputs = [
wrapGAppsHook4
gobject-introspection
gi-crystal
] ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];

buildInputs = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- a/src/doc2dash/doc_set_builder.cr 2023-07-19 14:00:06.864770147 +0300
+++ b/src/doc2dash/doc_set_builder.cr 2023-07-19 13:59:35.440707740 +0300
--- a/src/doc2dash/docset_builder.cr 2024-04-20 10:45:32.000673168 +0300
+++ b/src/doc2dash/docset_builder.cr 2024-04-20 10:45:56.072895349 +0300
@@ -44,6 +44,7 @@
real_dest = @html_dest.join(dest || source)
Dir.mkdir_p(Path.new(real_dest).dirname)
Expand Down
39 changes: 39 additions & 0 deletions pkgs/applications/misc/rtfm/make.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--- a/Makefile 2024-04-20 10:28:36.697545022 +0300
+++ b/Makefile 2024-04-20 10:37:55.591657540 +0300
@@ -7,8 +7,10 @@
shards build --debug -Dpreview_mt

configure:
- shards install
- ./bin/gi-crystal
+ mkdir bin/
+ cd lib/gi-crystal && shards build -Dpreview_mt --release --no-debug
+ cd ../..
+ cp lib/gi-crystal/bin/gi-crystal bin/ && ./bin/gi-crystal

rtfm:
shards build --release -Dpreview_mt rtfm
@@ -16,10 +18,10 @@
docsets: crystal-docset gtk-docset

crystal-docset:
- crystal run src/doc2dash/create_crystal_docset.cr
+ crystal src/doc2dash/create_crystal_docset.cr "@crystal@/share/doc/crystal/api"

gtk-docset:
- crystal run src/doc2dash/create_gtk_docset.cr
+ crystal src/doc2dash/create_gtk_docset.cr "gtk-doc/"

test: crystal-docset gtk-docset
crystal spec
@@ -28,8 +30,10 @@
install -D -m 0755 bin/rtfm $(DESTDIR)$(PREFIX)/bin/rtfm
install -D -m 0644 data/io.github.hugopl.rtfm.desktop $(DESTDIR)$(PREFIX)/share/applications/io.github.hugopl.rtfm.desktop
install -D -m 0644 data/icons/hicolor/scalable/apps/io.github.hugopl.rtfm.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/io.github.hugopl.rtfm.svg
+ gtk4-update-icon-cache --ignore-theme-index $(PREFIX)/share/icons/hicolor
# Settings schema
install -D -m644 data/io.github.hugopl.rtfm.gschema.xml $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/io.github.hugopl.rtfm.gschema.xml
+ glib-compile-schemas $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas
# docsets
mkdir -p $(DESTDIR)$(PREFIX)/share/rtfm/docsets/
cp -r data/Crystal.docset $(DESTDIR)$(PREFIX)/share/rtfm/docsets/
11 changes: 0 additions & 11 deletions pkgs/applications/misc/rtfm/patches/friendly-docs-path.patch

This file was deleted.

21 changes: 0 additions & 21 deletions pkgs/applications/misc/rtfm/patches/make.patch

This file was deleted.

20 changes: 10 additions & 10 deletions pkgs/applications/misc/rtfm/shards.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
};
fzy = {
url = "https://github.com/hugopl/fzy.git";
rev = "v0.5.5";
sha256 = "1zk95m43ymx9ilwr6iw9l44nkmp4sas28ib0dkr07hkhgrkw68sv";
rev = "6c2395bcdea1889969d0d08c16163c276fe4e473";
sha256 = "0vpradafkwckfsq7wqrgkpsli7bfmgc27d38q06l1jzq0z0j92rw";
};
gio = {
url = "https://github.com/hugopl/gio.cr.git";
rev = "v0.2.1";
sha256 = "0vl5lpvhhdi9pvyl12smag0i3dwj1jjz1zzilc8ai0wjrnbnwlxs";
gi-crystal = {
url = "https://github.com/hugopl/gi-crystal.git";
rev = "v0.22.2";
sha256 = "0bpa1f8iaf97z2kbgjc7nc8km7nd7bppiwna319lm2hvm8m5pw15";
};
gtk4 = {
url = "https://github.com/hugopl/gtk4.cr.git";
rev = "v0.16.0";
sha256 = "1bnnfy07246vwbjfwhziv2yw1g52pzhhrr25660fp3qcnw8q513w";
rev = "v0.16.1";
sha256 = "1cqkbh072y70l8g0p040vf50k920p32ry1larnwn9mqabd74jwaj";
};
harfbuzz = {
url = "https://github.com/hugopl/harfbuzz.cr.git";
Expand All @@ -31,8 +31,8 @@
};
pango = {
url = "https://github.com/hugopl/pango.cr.git";
rev = "v0.3.0";
sha256 = "1dg5bcbq11zww4xh68dq4ivnsz89yqsnxz81ggp4j9c9d6dhx0m4";
rev = "v0.3.1";
sha256 = "0xlf127flimnll875mcq92q7xsi975rrgdpcpmnrwllhdhfx9qmv";
};
sqlite3 = {
url = "https://github.com/crystal-lang/crystal-sqlite3.git";
Expand Down