-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ stdenv | ||
, lib | ||
, fetchFromGitHub | ||
, crystal | ||
, wrapGAppsHook4 | ||
, gobject-introspection | ||
, desktopToDarwinBundle | ||
, webkitgtk_6_0 | ||
, sqlite | ||
, gi-crystal | ||
, libadwaita | ||
, gtk4 | ||
, pango | ||
}: | ||
let | ||
gtk4' = gtk4.override { x11Support = true; }; | ||
pango' = pango.override { withIntrospection = true; }; | ||
in | ||
crystal.buildCrystalPackage rec { | ||
pname = "rtfm"; | ||
version = "0.2.2"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "hugopl"; | ||
repo = "rtfm"; | ||
rev = "v${version}"; | ||
name = "rtfm"; | ||
hash = "sha256-SmQq3hG94oV346dHtqTHC0xE4cWB3rspD3XXu+mSI8Q="; | ||
}; | ||
|
||
patches = [ | ||
# 1) fixed gi-crystal binding generator command | ||
# 2) removed `-v` arg to `cp` command to prevent build failure due to stdout buffer overflow | ||
# 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 | ||
|
||
# added chmod +w for copied docs to prevent error: | ||
# `Error opening file with mode 'wb': '.../style.css': Permission denied` | ||
./patches/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/" | ||
''; | ||
|
||
shardsFile = ./shards.nix; | ||
|
||
nativeBuildInputs = [ | ||
wrapGAppsHook4 | ||
gobject-introspection | ||
gi-crystal | ||
] ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ]; | ||
|
||
buildInputs = [ | ||
webkitgtk_6_0 | ||
sqlite | ||
libadwaita | ||
gtk4' | ||
pango' | ||
]; | ||
|
||
buildTargets = [ "configure" "rtfm" "docsets" ]; | ||
|
||
preBuild = '' | ||
mkdir gtk-doc/ | ||
for file in "${gtk4'.devdoc}"/share/doc/*; do | ||
ln -s "$file" "gtk-doc/$(basename "$file")" | ||
done | ||
for file in "${pango'.devdoc}"/share/doc/*; do | ||
ln -s "$file" "gtk-doc/$(basename "$file")" | ||
done | ||
for file in "${libadwaita.devdoc}"/share/doc/*; do | ||
ln -s "$file" "gtk-doc/$(basename "$file")" | ||
done | ||
''; | ||
|
||
meta = with lib; { | ||
description = "Dash/docset reader with built in documentation for Crystal and GTK APIs"; | ||
homepage = "https://github.com/hugopl/rtfm/"; | ||
license = licenses.mit; | ||
maintainers = with maintainers; [ sund3RRR ]; | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
pkgs/applications/misc/rtfm/patches/enable-write-permissions.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- 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 | ||
@@ -44,6 +44,7 @@ | ||
real_dest = @html_dest.join(dest || source) | ||
Dir.mkdir_p(Path.new(real_dest).dirname) | ||
File.copy(original, real_dest) | ||
+ File.chmod(real_dest, 0o600) | ||
dest || source | ||
end | ||
|
11 changes: 11 additions & 0 deletions
11
pkgs/applications/misc/rtfm/patches/friendly-docs-path.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- a/src/create_gtk_docset.cr 2023-07-17 14:28:04.882620660 +0300 | ||
+++ b/src/create_gtk_docset.cr 2023-07-17 14:27:09.660643747 +0300 | ||
@@ -136,7 +136,7 @@ | ||
end | ||
|
||
def find_modules : Array(Path) | ||
- basedir = Path.new("/usr/share/doc") | ||
+ basedir = Path.new(ARGV[0]? || "gtk-docs") | ||
MODULES.compact_map do |mod| | ||
print "#{mod.ljust(20, '.')}" | ||
mod_dir = basedir.join(mod) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- a/Makefile 2023-07-17 17:18:28.000000000 +0300 | ||
+++ b/Makefile 2023-07-19 12:13:44.627168135 +0300 | ||
@@ -4,8 +4,7 @@ | ||
all: configure .WAIT rtfm docsets | ||
|
||
configure: | ||
- shards install | ||
- ./bin/gi-crystal | ||
+ gi-crystal | ||
|
||
rtfm: | ||
shards build --release -s rtfm | ||
@@ -29,13 +28,15 @@ | ||
install -D -m644 data/io.github.hugopl.rtfm.gschema.xml $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/io.github.hugopl.rtfm.gschema.xml | ||
# docsets | ||
mkdir -p $(DESTDIR)$(PREFIX)/share/rtfm/docsets/ | ||
- cp -rv data/Crystal.docset $(DESTDIR)$(PREFIX)/share/rtfm/docsets/ | ||
- cp -rv data/Gtk4.docset $(DESTDIR)$(PREFIX)/share/rtfm/docsets/ | ||
+ cp -r data/Crystal.docset $(DESTDIR)$(PREFIX)/share/rtfm/docsets/ | ||
+ cp -r data/Gtk4.docset $(DESTDIR)$(PREFIX)/share/rtfm/docsets/ | ||
# License | ||
install -D -m0644 LICENSE $(DESTDIR)$(PREFIX)/share/licenses/rtfm/LICENSE | ||
# Changelog | ||
install -D -m0644 CHANGELOG.md $(DESTDIR)$(PREFIX)/share/doc/rtfm/CHANGELOG.md | ||
gzip -9fn $(DESTDIR)$(PREFIX)/share/doc/rtfm/CHANGELOG.md | ||
+ gtk4-update-icon-cache --ignore-theme-index $(PREFIX)/share/icons/hicolor | ||
+ glib-compile-schemas $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas | ||
|
||
uninstall: | ||
rm -f $(DESTDIR)$(PREFIX)/bin/rtfm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
db = { | ||
url = "https://github.com/crystal-lang/crystal-db.git"; | ||
rev = "v0.12.0"; | ||
sha256 = "1in8w2dz7nlhqgc9l6b3pi6f944m29nhbg3p5j40qzvsrr8lqaj7"; | ||
}; | ||
fzy = { | ||
url = "https://github.com/hugopl/fzy.git"; | ||
rev = "v0.5.5"; | ||
sha256 = "1zk95m43ymx9ilwr6iw9l44nkmp4sas28ib0dkr07hkhgrkw68sv"; | ||
}; | ||
gio = { | ||
url = "https://github.com/hugopl/gio.cr.git"; | ||
rev = "v0.1.0"; | ||
sha256 = "0vj35bi64d4hni18nrl8fmms306a0gl4zlxpf3aq08lh0sbwzhd8"; | ||
}; | ||
gtk4 = { | ||
url = "https://github.com/hugopl/gtk4.cr.git"; | ||
rev = "v0.15.0"; | ||
sha256 = "100j5k4sfc2dpj3nplzjcaxw1bwy3hsy5cw93asg00kda9h8dbb1"; | ||
}; | ||
harfbuzz = { | ||
url = "https://github.com/hugopl/harfbuzz.cr.git"; | ||
rev = "v0.2.0"; | ||
sha256 = "06wgqxwyib5416yp53j2iwcbr3bl4jjxb1flm7z103l365par694"; | ||
}; | ||
libadwaita = { | ||
url = "https://github.com/geopjr/libadwaita.cr.git"; | ||
rev = "23ce21d6400af7563ede0b53deea6d1f77436985"; | ||
sha256 = "09jz6r0yp4qsm47qcknzgkjxavr5j3dkxf2yjbw0jkaz1an58pfw"; | ||
}; | ||
pango = { | ||
url = "https://github.com/hugopl/pango.cr.git"; | ||
rev = "v0.2.0"; | ||
sha256 = "0dl3qrhi2ybylmvzx1x5gsznp2pcdkc50waxrljxwnf5avn8ixsf"; | ||
}; | ||
sqlite3 = { | ||
url = "https://github.com/crystal-lang/crystal-sqlite3.git"; | ||
rev = "v0.20.0"; | ||
sha256 = "0mqy6rc26i0sf2fdllbbzdhbd1d35npmpqqjz0b1n1vrzrm6fg05"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters