# Handle hardcoded paths in binary-only drivers / libraries?

**URL:** https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571
**Category:** Help
**Created:** [October 15, 2026, 7:53am UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571 "2026-10-15T07:53:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rkoe](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rkoe/32/107_2.png) [@rkoe](https://discourse.nixos.org/u/rkoe)
#### Post date: [October 15, 2026, 7:53am UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/1 "2026-10-15T07:53:56Z")

</div>

What’s the best practice to handle hardcoded paths in proprietary/binary-only drivers or libraries?

I want to use and package the proprietary SANE-scanner-drivers for Fujitsu / Ricoh SP-series document scanners (e.g. SP-1120, SP-1125, SP-1130), so I (and others) can use the scanners on NixOS. Fujitsu/Ricoh only provide a binary-only driver for Ubuntu. The libraries of this driver contain several hardcoded paths:

- /etc/sane.d/
- /opt/pfusp/
- /usr/bin/ps
- /usr/bin/grep

Since the driver does not find these paths, it fails.

So, what’s the best way here, so that the driver-libraries can find these paths/files?

1. Quick-and-dirty: manually add symlinks to the system. Works, but…
2. Patch the binary libraries? But the “new” paths are probably longer than the hardcoded ones, so that doesn’t work nicely.
3. Patch the binaries, so the hardcoded paths point to /etc/… (`/opt/pfusp` → `/etc/pfusp`, `/usr/bin` → `/etc/bin`) and add symlinks via environment.etc (`environment.etc."sane.d".source`, `environment.etc."pfusb".source`, `environment.etc."bin".source`).  
But this looks like a workaround in an unintended way.
4. buildFHSEnv? AFAIK does not work on libraries.
5. buildFHSEnv or wrap all binaries using the driver (xsane, simple-scan, gscan2pdf)? Looks wrong.
6. Create a custom nix-shell-configuration, which provides the paths, an run the binaries in there? Should work without patching the libraries, but seems a bit strange.
7. write wrapper-libraries?
8. …?

Currently, I’m considering and testing way 2 and 6, but maybe there’s a better way?

---

<div class="post-metadata">

### Author: ![eblechschmidt](https://discourse.nixos.org/user_avatar/discourse.nixos.org/eblechschmidt/32/27398_2.png) [@eblechschmidt](https://discourse.nixos.org/u/eblechschmidt)
#### Post date: [October 15, 2026, 8:07am UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/2 "2026-10-15T08:07:15Z")

</div>

Which scanner are you looking for? Did you take a look at how it is implemented for ScanSnap drivers? (see [nixpkgs/nixos/modules/services/hardware/sane.nix at a033e66ab94a6bedf2c3d58d93a36319d3cbbbaf · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/blob/a033e66ab94a6bedf2c3d58d93a36319d3cbbbaf/nixos/modules/services/hardware/sane.nix#L118) and [nixpkgs/pkgs/applications/graphics/sane/backends/default.nix at a033e66ab94a6bedf2c3d58d93a36319d3cbbbaf · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/blob/a033e66ab94a6bedf2c3d58d93a36319d3cbbbaf/pkgs/applications/graphics/sane/backends/default.nix))

---

<div class="post-metadata">

### Author: ![rkoe](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rkoe/32/107_2.png) [@rkoe](https://discourse.nixos.org/u/rkoe)
#### Post date: [October 15, 2026, 9:52am UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/3 "2026-10-15T09:52:38Z")

</div>

Especially Fujitsu/Ricoh SP-1130N. They do not belong to the SnapScan-Series, and it looks like they use a different driver-approach (but I have not (yet) read the SnapScan-driver details).

The pfusp-driver works, but the question is, how the hardcoded paths in there should ideally be “patched”.

---

<div class="post-metadata">

### Author: ![eblechschmidt](https://discourse.nixos.org/user_avatar/discourse.nixos.org/eblechschmidt/32/27398_2.png) [@eblechschmidt](https://discourse.nixos.org/u/eblechschmidt)
#### Post date: [October 15, 2026, 10:15am UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/4 "2026-10-15T10:15:35Z")

</div>

No, but someone extracted the relevant files and those are provided as a package. Maybe even the extraction could be automated. That package is then provided to the sane backend.

---

<div class="post-metadata">

### Author: ![rkoe](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rkoe/32/107_2.png) [@rkoe](https://discourse.nixos.org/u/rkoe)
#### Post date: [October 17, 2026, 11:05pm UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/5 "2026-10-17T23:05:35Z")

</div>

No, that does not work.  
As expected, the SnapScan-drivers work completely differently: There is an open-source-driver, which needs a firmware-file to work. The Fujitsu/Ricoh/PFU SP-series driver in contrast consists of binary-only libraries.

I’ve now packaged the Fujitsu/Ricoh/PFU SP-series driver using way 6: The package contains the driver and a nix-shell-configuration (+a shell-scipt to start it), which provides a modified root-filesystem with the necessary paths for the binary-only driver. To make the driver work, the user has to start this nix-shell and run e.g. scanimage, xsane, simple-scan or gscan2pdf from inside this shell.  
Is this a recommended way, or is an other way (e.g. (3) or (7)?) recommended over (6)?

---

<div class="post-metadata">

### Author: ![Frontear](https://discourse.nixos.org/user_avatar/discourse.nixos.org/frontear/32/27055_2.png) [@Frontear](https://discourse.nixos.org/u/Frontear)
#### Post date: [October 18, 2026, 4:20am UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/6 "2026-10-18T04:20:41Z")

</div>

Sounds like maybe a `bwrap` wrapper might be what you need?

---

<div class="post-metadata">

### Author: ![rkoe](https://discourse.nixos.org/user_avatar/discourse.nixos.org/rkoe/32/107_2.png) [@rkoe](https://discourse.nixos.org/u/rkoe)
#### Post date: [October 20, 2026, 8:05pm UTC](https://discourse.nixos.org/t/handle-hardcoded-paths-in-binary-only-drivers-libraries/80571/7 "2026-10-20T20:05:03Z")

</div>

Yes, I’ve used bwrap in the nix-shell-configuration.
