diff --git a/modules/services/calibre.nix b/modules/services/calibre.nix index 8a72a24..21c9707 100644 --- a/modules/services/calibre.nix +++ b/modules/services/calibre.nix @@ -48,18 +48,20 @@ in { }]; # Create directory and set permissions - system.activationScripts.calibreLibrary.text = '' - if [ ! -d "${libraryPath}" ]; then - $DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath} - fi - if [ ! "$(stat -c "%G" ${libraryPath})" = "calibre-web" ]; then - $DRY_RUN_CMD chown $VERBOSE_ARG -R calibre-web:calibre-web ${libraryPath} - fi - if [ ! "$(stat -c "%a" ${libraryPath})" = "775" ]; then - $DRY_RUN_CMD chmod $VERBOSE_ARG 0775 ${libraryPath} - $DRY_RUN_CMD chmod $VERBOSE_ARG -R 0640 ${libraryPath}/* - fi - ''; + systemd.services.calibre-library = { + requiredBy = [ "calibre-web.service" ]; + before = [ "calibre-web.service" ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + script = '' + mkdir --parents ${libraryPath} + chown -R calibre-web:calibre-web ${libraryPath} + chmod 0775 ${libraryPath} + chmod -R 0640 ${libraryPath}/* + ''; + }; };