Skip to content

nixos/calibre-web: fix book cover not showing up due to cache directory defaults to cps path under /nix/store/ #432604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stepbrobd
Copy link
Member

@stepbrobd stepbrobd commented Aug 10, 2025

the default cache directory is set to the constants.py's directory (under /nix/store/ obviously) if CACHE_DIR environment variable is not present

calibre-web server will return 500 for all the book covers

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 9.needs: reviewer This PR currently has no reviewers requested and needs attention. labels Aug 10, 2025
@stepbrobd stepbrobd requested a review from pborzenkov August 11, 2025 12:06
@nixpkgs-ci nixpkgs-ci bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Aug 11, 2025
@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 11, 2025
@stepbrobd
Copy link
Member Author

@pborzenkov sorry for the ping again

quick question, i tried this patch on my pre-existing deployment but i had to go manually create the cache directory and set the permission for it to work

would systemd only create directories for fresh units? or we’ll have to add a pre start script to create the cache directory?

i saw quite a few modules either creating directories in pre start script, or they just set the cache directory and permissions in service config (our approach here) and let systemd handle it for them

@pborzenkov
Copy link
Contributor

@stepbrobd

I think it needs to be a relative path. From systemd.exec manpage:

RuntimeDirectory=, StateDirectory=, CacheDirectory=, LogsDirectory=, ConfigurationDirectory=
These options take a whitespace-separated list of directory names. The specified directory names must be relative, and may not include "..".

@stepbrobd
Copy link
Member Author

But state directory (by default) is also an absolute path though, maybe this was able to pass because of calibre-web itself will try to create it on its own?

Do you think it'd be better to change both state and cache directories to relative path by default in this patch or just leave them as is?

@pborzenkov
Copy link
Contributor

@stepbrobd

But state directory (by default) is also an absolute path though, maybe this was able to pass because of calibre-web itself will try to create it on its own?

The StateDirectory unit parameter is only defined if cfg.dataDir doesn't start with /:

// lib.optionalAttrs (!(lib.hasPrefix "/" cfg.dataDir)) {
StateDirectory = cfg.dataDir;
};

Otherwise the directory is created via systemd temp files:
systemd.tmpfiles.settings = lib.optionalAttrs (lib.hasPrefix "/" cfg.dataDir) {

In both cases the actual path that's passed to calibre-web is absolute:

dataDir = if lib.hasPrefix "/" cfg.dataDir then cfg.dataDir else "/var/lib/${cfg.dataDir}";

So for CacheDirectory you can specify calibre-web, but set CACHE_DIR environment variable to /var/cache/calibre-web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants