diff options
author | Linnnus <[email protected]> | 2024-10-01 15:06:20 +0200 |
---|---|---|
committer | Linnnus <[email protected]> | 2024-10-01 15:06:20 +0200 |
commit | 98cd14bce3952bc8f777b40ea1ca557bf2fc8361 (patch) | |
tree | 6e280f9f4121d36121c01a7d1c9d88583de603a7 | |
parent | da255cfe08fef9d3f0aa37049d1ce5e758f4cc5d (diff) |
qbittorent: Fix creation logic
After attempting to use this configuration on another device, it turns
out that the persistent data directories were being created with the
wrong permissions.
-rw-r--r-- | hosts/ahmed/torrenting/save-path.nix | 9 | ||||
-rw-r--r-- | modules/nixos/qbittorrent/default.nix | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/hosts/ahmed/torrenting/save-path.nix b/hosts/ahmed/torrenting/save-path.nix index d58babb..293c00f 100644 --- a/hosts/ahmed/torrenting/save-path.nix +++ b/hosts/ahmed/torrenting/save-path.nix @@ -45,10 +45,15 @@ in { categoriesJson = lib.genAttrs categories (c: {"save_path" = "${downloadPath}/${c}";}); categoriesFile = (pkgs.formats.json {}).generate "categories.json" categoriesJson; categoriesPath = "${config.services.qbittorrent.profile}/qBittorrent/config/categories.json"; - in - pkgs.writeShellScript "qbittorrent-create-categories.sh" '' + + script = pkgs.writeShellScript "qbittorrent-create-categories.sh" '' + # FIXME: Creation and chowning are duplicated between this and qBittorrent service definition. + mkdir -p /var/lib/qBittorrent/qBittorrent/config ln -s -f ${categoriesFile} ${categoriesPath} + chown --recursive qbittorrent:qbittorrent -- ${config.services.qbittorrent.profile}/qBittorrent/config/ ''; + in + "!${script}"; }; }; diff --git a/modules/nixos/qbittorrent/default.nix b/modules/nixos/qbittorrent/default.nix index ad4b7e6..5f79f8a 100644 --- a/modules/nixos/qbittorrent/default.nix +++ b/modules/nixos/qbittorrent/default.nix @@ -136,12 +136,16 @@ in { # Create data directory if it doesn't exist if ! test -d ${cfg.profile}; then - echo "Creating initial qBittorrent data directory in: ${cfg.profile}" - install -d -m 0755 -o ${cfg.user} -g ${cfg.group} ${cfg.profile}/qBittorrent/config/ + echo "Creating initial qBittorrent config directory in: ${cfg.profile}" + mkdir -p ${cfg.profile}/qBittorrent/config/ fi # Force-apply configuration. ${pkgs.crudini}/bin/crudini --ini-options=nospace --merge ${configPath} <${settingsFile} + + # Fix permissions in directory. This not only necessary for initial setup, but also after + # changing the option `services.qbittorrent.user`. + chown --recursive ${cfg.user}:${cfg.group} -- ${cfg.profile} ''; in # Requires full permissions to create data directory, hence the "!". |