Skip to content

nixos/qbittorrent: copy config instead of symlinking to nix store#482534

Open
Titaniumtown wants to merge 1 commit intoNixOS:masterfrom
Titaniumtown:pr/qbittorrent-config-fix
Open

nixos/qbittorrent: copy config instead of symlinking to nix store#482534
Titaniumtown wants to merge 1 commit intoNixOS:masterfrom
Titaniumtown:pr/qbittorrent-config-fix

Conversation

@Titaniumtown
Copy link
Contributor

The serverConfig option generates a declarative config file, but the current implementation uses a tmpfiles L+ rule to create a symlink to the config in the nix store. This doesn't work because:

  1. qBittorrent reads its config and then writes back to it at runtime
  2. The nix store is read-only
  3. qBittorrent silently falls back to default/stale settings
    This PR changes the approach to use ExecStartPre to copy the declarative config to the runtime location before qBittorrent starts. With this change, WebUI changes won't persist across service restarts.

I came across this issue when trying to get qBittorrent working again once Vuetorrent was updated. Because of the update, the nix store path changed, breaking the WebUI.

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.

@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. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 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/` labels Jan 22, 2026
Copy link
Member

@sith-lord-vader sith-lord-vader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Much-needed change

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. and removed 9.needs: reviewer This PR currently has no reviewers requested and needs attention. labels Jan 22, 2026
@undefined-landmark undefined-landmark mentioned this pull request Jan 25, 2026
19 tasks
Copy link
Contributor

@undefined-landmark undefined-landmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, came across it by coincidence. Pinging @fsnkty as well, as we're listed as maintainers.

First off, I think moving to copy/install instead of symlinking is the right way to go.

Some sidenotes:

Before the initial merge I did some digging and found out that qbit deletes the config before writing, as can be seen in the source code. So when trying to write to the config file it will remove the symlink and than write a new config. That explained why the symlink disappeared and qbit can write to the config. I'm not certain if this behavior is still the same, but I expect it is.

Currently changes made in the webUI also do not persist across reboots, as tested.

So this is what happens at the moment

  • symlink gets made
  • optionally: user makes changes
  • qbit deletes symlink and writes config
    A restart or changes to the declarative config repeat this cycle. So changes do not persist when using a declarative config.

@Titaniumtown Titaniumtown force-pushed the pr/qbittorrent-config-fix branch from a582d37 to fda09fe Compare February 20, 2026 05:16
@Titaniumtown
Copy link
Contributor Author

@undefined-landmark sorry about the late reply. my latest change addressed your comment. Thanks!

@undefined-landmark
Copy link
Contributor

Thanks. In another PR of mine I received feedback that tmpfiles is preferred over install/cp: #483956 (comment).

Same applies here I assume. Probably tmpfiles can simply be changed from symlinking to copying?

@Titaniumtown
Copy link
Contributor Author

@undefined-landmark I don't know how to use tmpfiles that way, could you provide an example?

@Titaniumtown
Copy link
Contributor Author

I understand what you are requesting now. I am pushing a fix shortly.

@Titaniumtown Titaniumtown force-pushed the pr/qbittorrent-config-fix branch from fda09fe to 8018e46 Compare February 23, 2026 22:46
@Titaniumtown
Copy link
Contributor Author

Take a look now!

@undefined-landmark
Copy link
Contributor

undefined-landmark commented Feb 25, 2026

Yes, that's what I had in my mind.

With this change we do duplicate part of configFile = pkgs.writeText "qBittorrent.conf" (gendeepINI cfg.serverConfig);. I believe we don't need to write the config file to the nix store anymore, now that it doesn't get symlinked. So you could adapt that line and restartTriggers = optionals (cfg.serverConfig != { }) [ configFile ];

Any opinions @fsnkty @kira-bruneau?

@Titaniumtown Titaniumtown force-pushed the pr/qbittorrent-config-fix branch from 8018e46 to e061b00 Compare March 3, 2026 04:06
@Titaniumtown
Copy link
Contributor Author

@undefined-landmark Pushed!

Copy link
Contributor

@undefined-landmark undefined-landmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the frequent back and forth. One last comment. Tests are building fine, almost there!

@@ -170,7 +169,7 @@ in
"nss-lookup.target"
];
wantedBy = [ "multi-user.target" ];
restartTriggers = optionals (cfg.serverConfig != { }) [ configFile ];
restartTriggers = optionals (cfg.serverConfig != { }) [ (gendeepINI cfg.serverConfig) ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We repeat line 159 here. We could create a variable, e.g. configContent, in the let block. That variable can than be used in both this line and in line 159.

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.

3 participants