Skip to content

Commit a4adad1

Browse files
committed
Add Linux support with Nix packaging, Flatpak, desktop integration, and CI/CD
1 parent 6f3a5ff commit a4adad1

File tree

22 files changed

+677
-39
lines changed

22 files changed

+677
-39
lines changed

.envrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Optional: Automatically load Nix development environment when entering this directory
2+
# Requires direnv (https://direnv.net/) and nix-direnv for automatic shell activation
3+
# If you don't use direnv, run 'nix develop' manually instead
4+
use flake

.github/workflows/build.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
permissions:
66
contents: write
77
jobs:
8-
build:
8+
build-windows:
99
runs-on: windows-latest
1010
steps:
1111
- name: Checkout repository
@@ -57,11 +57,46 @@ jobs:
5757
- name: Upload artifacts
5858
uses: actions/upload-artifact@v4
5959
with:
60-
name: paperback-build
60+
name: paperback-windows
6161
path: |
6262
build/paperback.zip
6363
build/paperback_setup.exe
6464
retention-days: 30
65+
66+
build-linux-flatpak:
67+
runs-on: ubuntu-latest
68+
container:
69+
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-49
70+
options: --privileged
71+
steps:
72+
- uses: actions/checkout@v4
73+
with:
74+
submodules: recursive
75+
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
76+
with:
77+
bundle: paperback.flatpak
78+
manifest-path: io.github.trypsynth.Paperback.yaml
79+
cache-key: flatpak-builder-${{ github.sha }}
80+
81+
release:
82+
needs: [build-windows, build-linux-flatpak]
83+
runs-on: ubuntu-latest
84+
if: github.event_name == 'push'
85+
steps:
86+
- name: Checkout repository
87+
uses: actions/checkout@v4
88+
with:
89+
fetch-depth: 0
90+
- name: Download Windows artifacts
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: paperback-windows
94+
path: windows-build
95+
- name: Download Linux Flatpak
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: paperback-x86_64.flatpak
99+
path: linux-build
65100
- name: Get latest tag reachable from HEAD
66101
id: get_tag
67102
shell: bash
@@ -91,8 +126,9 @@ jobs:
91126
## Commits since last release
92127
${{ steps.release_notes.outputs.commits }}
93128
files: |
94-
build/paperback.zip
95-
build/paperback_setup.exe
129+
windows-build/paperback.zip
130+
windows-build/paperback_setup.exe
131+
linux-build/paperback.flatpak
96132
prerelease: true
97133
env:
98134
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
build/
22
vcpkg/bin/
33
web/_site/
4+
result
5+
.direnv/
6+
.flatpak-builder/
7+
*.flatpak
8+
repo-flatpak/

CMakeLists.txt

Lines changed: 99 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
cmake_minimum_required(VERSION 3.21)
2+
3+
# Option to use system libraries instead of vcpkg (for Nix, Linux distros, etc.)
4+
option(USE_SYSTEM_LIBS "Use system libraries instead of vcpkg" OFF)
5+
6+
if(NOT USE_SYSTEM_LIBS)
27
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/bin/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")
38
set(VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/vcpkg")
49
if(WIN32)
@@ -8,6 +13,7 @@ elseif(APPLE)
813
else()
914
set(VCPKG_TARGET_TRIPLET "x64-linux" CACHE STRING "Vcpkg triplet")
1015
endif()
16+
endif()
1117
project(paperback VERSION 0.6.1 LANGUAGES CXX)
1218

1319
set(CMAKE_CXX_STANDARD 20)
@@ -28,15 +34,32 @@ if(CLANG_TIDY_EXE)
2834
add_custom_target(lint COMMAND ${CLANG_TIDY_EXE} -warnings-as-errors=* --header-filter=^${CMAKE_SOURCE_DIR}/src/ --extra-arg=/EHsc ${ALL_SOURCE_FILES} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} USES_TERMINAL)
2935
endif()
3036

31-
find_package(chmlib CONFIG REQUIRED)
37+
if(USE_SYSTEM_LIBS)
38+
# Find system libraries (for Nix, system package managers, etc.)
39+
find_library(CHMLIB_LIBRARY NAMES chm REQUIRED)
40+
find_path(CHMLIB_INCLUDE_DIR NAMES chm_lib.h REQUIRED)
41+
find_library(LEXBOR_LIBRARY NAMES lexbor REQUIRED)
42+
find_path(LEXBOR_INCLUDE_DIR NAMES lexbor/html/html.h REQUIRED)
43+
find_library(MBEDCRYPTO_LIBRARY NAMES mbedcrypto REQUIRED)
44+
find_path(MBEDTLS_INCLUDE_DIR NAMES mbedtls/md.h REQUIRED)
45+
find_library(PDFIUM_LIBRARY NAMES pdfium REQUIRED)
46+
find_path(PDFIUM_INCLUDE_DIR NAMES fpdfview.h REQUIRED)
47+
find_library(PUGIXML_LIBRARY NAMES pugixml REQUIRED)
48+
find_path(PUGIXML_INCLUDE_DIR NAMES pugixml.hpp REQUIRED)
49+
find_package(wxWidgets REQUIRED base core net)
50+
else()
51+
# Use vcpkg libraries (default)
52+
find_package(chmlib CONFIG REQUIRED)
53+
find_package(lexbor CONFIG REQUIRED)
54+
find_package(MbedTLS CONFIG REQUIRED)
55+
find_package(pdfium CONFIG REQUIRED)
56+
find_package(pugixml CONFIG REQUIRED)
57+
find_package(wxWidgets CONFIG REQUIRED)
58+
endif()
59+
3260
find_package(Gettext)
33-
find_package(lexbor CONFIG REQUIRED)
3461
find_package(maddy CONFIG REQUIRED)
35-
find_package(MbedTLS CONFIG REQUIRED)
3662
find_package(nlohmann_json CONFIG REQUIRED)
37-
find_package(pdfium CONFIG REQUIRED)
38-
find_package(pugixml CONFIG REQUIRED)
39-
find_package(wxWidgets CONFIG REQUIRED)
4063

4164
if(GETTEXT_FOUND)
4265
find_program(XGETTEXT_EXECUTABLE NAMES xgettext)
@@ -93,17 +116,42 @@ if(WIN32)
93116
else()
94117
add_executable(paperback ${SRC_FILES})
95118
endif()
96-
target_link_libraries(paperback PRIVATE
97-
chmlib::chm
98-
lexbor::lexbor
99-
maddy::maddy
100-
MbedTLS::mbedcrypto
101-
pdfium::pdfium
102-
pugixml::pugixml
103-
wx::base
104-
wx::core
105-
wx::net
106-
)
119+
120+
if(USE_SYSTEM_LIBS)
121+
target_include_directories(paperback PRIVATE
122+
${CHMLIB_INCLUDE_DIR}
123+
${LEXBOR_INCLUDE_DIR}
124+
${MBEDTLS_INCLUDE_DIR}
125+
${PDFIUM_INCLUDE_DIR}
126+
${PUGIXML_INCLUDE_DIR}
127+
${wxWidgets_INCLUDE_DIRS}
128+
)
129+
target_compile_options(paperback PRIVATE ${wxWidgets_CXX_FLAGS})
130+
target_compile_definitions(paperback PRIVATE ${wxWidgets_DEFINITIONS})
131+
target_link_libraries(paperback PRIVATE
132+
${CHMLIB_LIBRARY}
133+
${LEXBOR_LIBRARY}
134+
maddy::maddy
135+
${MBEDCRYPTO_LIBRARY}
136+
nlohmann_json::nlohmann_json
137+
${PDFIUM_LIBRARY}
138+
${PUGIXML_LIBRARY}
139+
${wxWidgets_LIBRARIES}
140+
)
141+
else()
142+
target_link_libraries(paperback PRIVATE
143+
chmlib::chm
144+
lexbor::lexbor
145+
maddy::maddy
146+
MbedTLS::mbedcrypto
147+
nlohmann_json::nlohmann_json
148+
pdfium::pdfium
149+
pugixml::pugixml
150+
wx::base
151+
wx::core
152+
wx::net
153+
)
154+
endif()
107155

108156
if (MSVC)
109157
target_compile_options(paperback PRIVATE /W4 /permissive- /WX)
@@ -172,3 +220,37 @@ if(WIN32)
172220
else()
173221
add_custom_target(release DEPENDS package)
174222
endif()
223+
224+
# Installation rules (Linux desktop integration)
225+
if(UNIX AND NOT APPLE)
226+
# Install binary
227+
install(TARGETS paperback DESTINATION bin)
228+
229+
# Install desktop file
230+
install(FILES ${CMAKE_SOURCE_DIR}/paperback.desktop
231+
DESTINATION share/applications)
232+
233+
# Install icons
234+
foreach(size 16 32 48 64 128 256)
235+
install(FILES ${CMAKE_SOURCE_DIR}/icons/hicolor/${size}x${size}/apps/paperback.png
236+
DESTINATION share/icons/hicolor/${size}x${size}/apps)
237+
endforeach()
238+
239+
# Install documentation
240+
if(TARGET doc)
241+
install(FILES ${CMAKE_BINARY_DIR}/readme.html
242+
DESTINATION share/doc/paperback)
243+
endif()
244+
245+
# Install translations
246+
if(MO_FILES)
247+
foreach(mo_file ${MO_FILES})
248+
get_filename_component(mo_dir ${mo_file} DIRECTORY)
249+
get_filename_component(lang_dir ${mo_dir} DIRECTORY)
250+
get_filename_component(lang ${lang_dir} NAME)
251+
install(FILES ${mo_file}
252+
DESTINATION share/locale/${lang}/LC_MESSAGES
253+
RENAME paperback.mo)
254+
endforeach()
255+
endif()
256+
endif()

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Paperback is a lightweight, fast, and accessible ebook and document reader built
1212
* Command-line file opening for 'Open With' integration.
1313

1414
## Building
15+
16+
### Windows (VCPKG)
17+
1518
We use VCPKG for managing dependencies. Currently we manage our own VCPKG installation through a submodule. As such, make sure to clone Paperback recursively:
1619

1720
```batch
@@ -39,6 +42,50 @@ Optional tools:
3942
- `pandoc` on your `PATH` to generate the HTML readme during the build.
4043
- `gettext` tools (`xgettext`, `msgfmt`, `msgmerge`) on your `PATH` to generate the translation template and compile translations.
4144

45+
### Linux
46+
47+
For building with CMake, you'll need CMake 3.21+, a C++20 compiler, and dependencies:
48+
- wxWidgets 3.2+
49+
- chmlib, lexbor, mbedtls, pdfium, pugixml, nlohmann-json
50+
51+
```bash
52+
cmake -B build -DUSE_SYSTEM_LIBS=ON -DCMAKE_BUILD_TYPE=Release
53+
cmake --build build
54+
sudo cmake --install build
55+
```
56+
57+
Optional tools:
58+
- `pandoc` for HTML readme generation
59+
- `gettext` tools for translations
60+
61+
### Linux (Nix)
62+
63+
**Run directly:**
64+
```bash
65+
nix run github:trypsynth/paperback
66+
```
67+
68+
**Install to profile:**
69+
```bash
70+
nix profile install github:trypsynth/paperback
71+
```
72+
73+
**Build from source:**
74+
```bash
75+
# Clone repository
76+
git clone --recursive https://github.com/trypsynth/paperback
77+
cd paperback
78+
79+
# Build and run
80+
nix run .#paperback
81+
82+
# Or build specific outputs:
83+
nix build .#paperback # Nix derivation
84+
85+
# Build Flatpak:
86+
flatpak-builder --force-clean --repo=repo build io.github.trypsynth.Paperback.yaml
87+
```
88+
4289
## Contributing
4390
Contributions are welcome! Whether through issues, pull requests, discussions, or other means, your interest is appreciated.
4491

doc/readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
Paperback is a lightweight, fast, and accessible ebook/document reader designed to make reading fun and seamless, regardless of the file format being used or the user's preferences.
44

55
## System Requirements
6-
Paperback currently runs on Windows 7 through Windows 11. It's possible it runs on earlier versions of Windows too and/or can be built in such a way that it will, but this hasn't been tested yet. Support for other platforms is planned for a future version.
6+
**Windows:** Windows 7 through Windows 11. It's possible it runs on earlier versions of Windows too and/or can be built in such a way that it will, but this hasn't been tested yet.
7+
8+
**Linux:** Any modern distribution with glibc 2.38+ (e.g., Ubuntu 24.04+, Fedora 39+, Arch Linux). Alternatively, use the Flatpak version for broader compatibility with older distributions.
79

810
## Features
911
* Incredibly fast and standalone.

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)