diff --git a/common/server/nextcloud.nix b/common/server/nextcloud.nix index 07e8c83..d0927da 100644 --- a/common/server/nextcloud.nix +++ b/common/server/nextcloud.nix @@ -11,6 +11,9 @@ let # Hardcoded public ip of ponyo... I wish I didn't need this... public_ip_address = "147.135.114.130"; + + nixManagedApps = builtins.attrNames cfg.extraApps; + nixManagedAppsPattern = lib.concatStringsSep "|" nixManagedApps; in { config = lib.mkIf cfg.enable { @@ -42,6 +45,18 @@ in # Allows installing Apps from the UI (might remove later) appstoreEnable = true; }; + + # Override the update service to skip Nix-managed apps, which would otherwise + # get duplicated into store-apps/ and cause PHP class redeclaration errors. + systemd.services.nextcloud-update-plugins = { + path = [ config.services.nextcloud.occ ]; + serviceConfig.ExecStart = lib.mkForce (toString (pkgs.writeShellScript "nextcloud-update-non-nix-apps" '' + apps=$(nextcloud-occ app:update --showonly | awk '{print $1}' | grep -vE '^(${nixManagedAppsPattern})$' || true) + for app in $apps; do + nextcloud-occ app:update "$app" + done + '')); + }; age.secrets.nextcloud-pw = { file = ../../secrets/nextcloud-pw.age; owner = "nextcloud";