Skip to content
Open
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.epub
*.epub
.direnv
result
target/**
5 changes: 5 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ gen-bindings:
cargo test -p bene-epub export_bindings
cp -r crates/bene-epub/bindings ../js/packages/bene-types/src/

[working-directory: 'js']
build: gen-bindings
depot -p bene-reader build
depot -p bene-desktop build

[working-directory: 'rs']
build-native: gen-bindings
cargo tauri build
Expand Down
137 changes: 137 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Bene - An EPUB reading system
#
# Usage:
# nix build - Build using pre-built binary from GitHub releases (fast)
# nix build .#from-source - Build from source (slow, for testing patches)
# nix develop - Enter development shell with Rust, Node, pnpm, depot
# nix run -- /path/to.epub - Run the reader directly
#
# The default package downloads the .deb from GitHub releases and patches it
# for NixOS using autoPatchelfHook. Only x86_64-linux is supported for the
# binary package.
#
# To update to a new release:
# 1. Update version in nix/bene-bin.nix
# 2. Run: nix-prefetch-url https://github.com/nota-lang/bene/releases/download/v<VERSION>/Bene.Reader_<VERSION>_amd64.deb
# 3. Convert hash: nix hash convert --hash-algo sha256 <hash>
# 4. Update hash in nix/bene-bin.nix
#
{
description = "Bene - An EPUB reading system with Rust backend and JavaScript frontend";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
depot = {
url = "github:cognitive-engineering-lab/depot";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, rust-overlay, depot }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};

rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
depotPkg = depot.packages.${system}.default;

src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.gitTracked ./.;
};
in
{
# Default package: Pre-built binary (fast, recommended)
packages.default = pkgs.callPackage ./nix/bene-bin.nix { };

# From-source build (for development/testing patches)
packages.from-source = pkgs.callPackage ./nix/bene-src.nix {
inherit rustToolchain depotPkg src;
pnpm = pkgs.pnpm_9;
};

# Development shell with all tools
devShells.default = pkgs.callPackage ./nix/devshell.nix {
inherit rustToolchain depotPkg;
};

# Formatter for `nix fmt`
formatter = pkgs.nixpkgs-fmt;
});
}
87 changes: 87 additions & 0 deletions nix/bene-bin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Pre-built binary package for Bene
# Downloads the .deb from GitHub releases and patches it for NixOS
{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, wrapGAppsHook3
, gtk3
, webkitgtk_4_1
, libsoup_3
, glib
, glib-networking
, openssl
, libayatana-appindicator
}:

stdenv.mkDerivation rec {
pname = "bene";
version = "0.1.3";

src = fetchurl {
url = "https://github.com/nota-lang/bene/releases/download/v${version}/Bene.Reader_${version}_amd64.deb";
hash = "sha256-zO4WlKmDkZc/bIPB+3mcTcj1xfUbrVo4sHGNvaoGjrI=";
};

unpackCmd = "${dpkg}/bin/dpkg-deb -x $curSrc .";
sourceRoot = ".";

nativeBuildInputs = [
autoPatchelfHook
wrapGAppsHook3
dpkg
];

buildInputs = [
gtk3
webkitgtk_4_1
libsoup_3
glib
glib-networking
openssl
libayatana-appindicator
];

dontConfigure = true;
dontBuild = true;

installPhase = ''
runHook preInstall

mkdir -p $out/bin $out/lib $out/share

# Install the main binary (upstream names it bene-app)
install -Dm755 usr/bin/bene-app $out/bin/bene

# Install bundled resources (bene-reader assets)
if [ -d "usr/lib/Bene Reader" ]; then
cp -r "usr/lib/Bene Reader" "$out/lib/"
fi

# Install desktop file
if [ -d usr/share/applications ]; then
cp -r usr/share/applications $out/share/
fi

# Install icons
if [ -d usr/share/icons ]; then
cp -r usr/share/icons $out/share/
fi

runHook postInstall
'';

postFixup = ''
wrapProgram $out/bin/bene \
--prefix GIO_EXTRA_MODULES : "${glib-networking}/lib/gio/modules"
'';

meta = with lib; {
description = "An EPUB reading system";
homepage = "https://github.com/nota-lang/bene";
license = with licenses; [ mit asl20 ];
platforms = [ "x86_64-linux" ];
mainProgram = "bene";
};
}
Loading