# Getting Calibre working with camoufox and browserforge

**URL:** https://discourse.nixos.org/t/getting-calibre-working-with-camoufox-and-browserforge/80925
**Category:** Guides
**Created:** [November 4, 2026, 8:44am UTC](https://discourse.nixos.org/t/getting-calibre-working-with-camoufox-and-browserforge/80925 "2026-11-04T08:44:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![elkiehirvi](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/e/f05b48/32.png) [@elkiehirvi](https://discourse.nixos.org/u/elkiehirvi)
#### Post date: [November 4, 2026, 8:44am UTC](https://discourse.nixos.org/t/getting-calibre-working-with-camoufox-and-browserforge/80925/1 "2026-11-04T08:44:04Z")

</div>

Hi! I’m pretty new on Nixos, so this might be messy, so this is as much guide to getting Calibre working as a question on how I should do this more elegantly.

The Calibre Camoufox-functionality needs a local version of camoufox on Nix, the bundled one wont have a working environment. I created a hacky overlay (the first one so far) to provide Calibre access to camoufox and browserforge. This is for Calibre 9.17

Feast your eyes on this and despair!

> ```auto
> (final: prev: {
> calibre = prev.calibre.overrideAttrs (old:
> {
> buildInputs = old.buildInputs ++ [final.camoufox final.python314Packages.browserforge];
> 
> postPatch =
> (old.postPatch or "")
> + ''
> unwrapped=$(grep -o '/nix/store/[^/"]*camoufox-unwrapped[^/"]*' ${final.camoufox}/bin/camoufox | head -n1)
> test -n "$unwrapped" || { echo "could not find unwrapped camoufox"; exit 1; }
> 
> substituteInPlace setup/resources.py \
> --replace-fail "if not opts.system_camoufox:" "if False:" \
> --replace-fail "parts = opts.system_camoufox.split(os.pathsep)" "parts = '$unwrapped/bin/camoufox:$unwrapped/lib/camoufox'.split(os.pathsep)"
> '';
> preFixup =
> ''
> qtWrapperArgs+=(
> --prefix PYTHONPATH : ${final.python314Packages.makePythonPath [final.python314Packages.browserforge]}
> --prefix LD_LIBRARY_PATH : ${final.lib.makeLibraryPath [
> final.gtk3
> final.glib
> final.dbus-glib
> final.libGL
> final.libxkbcommon
> final.alsa-lib
> final.libpulseaudio
> final.pciutils
> final.libX11
> final.libXtst
> final.libXrandr
> final.libXcomposite
> final.libXdamage
> final.libXfixes
> final.libXcursor
> final.libXi
> final.libxcb
> final.wayland
> ]}
> )
> ''
> + old.preFixup;
> });
> })
> 
> ```

This might help someone with the same problem, but yes, some questions:

The hacky grep-substitution is because dealing with python whitespace within Nix code was difficult. Is there a better way to do this?

How would I go about bundling camoufox with calibre instead of relying on a system-wide setup?

I know the libraries are excessive, but I didn’t have enough time to build and check for what is needed one library at a time, so I added the some probable ones and decided to get back to it at some point.

edit: didn’t need to set camoufox fonts for functionality, so dropped that

---

<div class="post-metadata">

### Author: ![elkiehirvi](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/e/f05b48/32.png) [@elkiehirvi](https://discourse.nixos.org/u/elkiehirvi)
#### Post date: [November 20, 2026, 7:50am UTC](https://discourse.nixos.org/t/getting-calibre-working-with-camoufox-and-browserforge/80925/2 "2026-11-20T07:50:16Z")

</div>

Update: So, the smartest person who ever did a thing that I am, I managed to overlook, that the flake I used for camoufox (

```auto
camoufox-nix = {
url = "github:maximoffua/camoufox-nix";
inputs.nixpkgs.follows = "nixpkgs";
};

```

)  
also provides a prebuilt binary, so if you are using my solution and want to save yourself half an hour or so of compiling firefox from source, here you go:

```auto
(final: prev: let
camoufox = inputs.camoufox-nix.packages.${final.stdenv.hostPlatform.system}.c amoufox-bin;
in {
calibre = prev.calibre.overrideAttrs (old: {
buildInputs = old.buildInputs ++ \[camoufox final.python314Packages.browserforge\];

postPatch =
(old.postPatch or "")
+ ''
res=$(echo ${camoufox}/lib/camoufox-bin-\*)
bin="$res/camoufox-bin"

substituteInPlace setup/resources.py \\
--replace-fail "if not opts.system_camoufox:" "if False:" \\
--replace-fail "parts = opts.system_camoufox.split(os.pathsep)" "parts = '$bin:$res'.split(os.pathsep)"
'';

preFixup =
''
qtWrapperArgs+=(
--prefix PYTHONPATH : ${final.python314Packages.makePythonPath \[final.python314Packages.browserforge\]}
--prefix LD_LIBRARY_PATH : ${final.lib.makeLibraryPath \[
final.gtk3
final.glib
final.dbus-glib
final.libGL
final.libxkbcommon
final.alsa-lib
final.libpulseaudio
final.pciutils
final.libX11
final.libXtst
final.libXrandr
final.libXcomposite
final.libXdamage
final.libXfixes
final.libXcursor
final.libXi
final.libxcb
final.wayland
\]}
)
''
+ old.preFixup;
});
})

```
