25.11 How to avoid service postgresql starting automatically

system: "x86_64-linux"
multi-user?: yes
version: nix-env (Nix) 2.31.2
channels(root): "home-manager-25.11.tar.gz
nixos-25.11"
nixpkgs: /nix/store/sac0rlr0ca9774bik89x3scbf7xrvqyd-nixos-25.11/nixos

I use PostGreSQL on my NixOS seldom. That is why I used the following trick to avoid that the service is started automatically:

systemd.services.postgresql.wantedBy = pkgs.lib.mkForce [ ];

cf post How to avoid service postgresql starting automatically .

But since the update to 25.11 the service automatically on system boot again; the trick above does not work anymore.

What can I do to avoid the startUp of PostGres ?

Here my NixConfig (prop.installPostgresql = true for this machine)

services.postgresql = if prop.installPostgresql then {
  authentication = pkgs.lib.mkOverride 10 ''
    local all all trust
    host all all 127.0.0.1/32 trust
    host all all ::1/128 trust
  '';
  enable = true;
  enableTCPIP = false;
  extensions = with pkgs.postgresql_18.pkgs; [ pg_rational pg_repack ];
  package = pkgs.postgresql_18;
} else {
  enable = false;
};

Try wantedBy = lib.mkAfter [ "" ], that uses systemds overriding mechanisms instead. Also, make sure that no other service puts a wants.

The multi-user.target bound is now on postgresql.target: nixpkgs/nixos/modules/services/databases/postgresql.nix at 89dbf01df72eb5ebe3b24a86334b12c27d68016a · NixOS/nixpkgs · GitHub

So try the same mkForce but with postgresql.target — you should remove the overrides for postgresql.service. (Also, when starting Postgres manually, start the target, not the service.)

Thanks for your help.
The following avoids PostGres being started automatically:

systemd.targets.postgresql.wantedBy = pkgs.lib.mkForce [ ];

see systemd: postgres as target not service

I do not know whether I start the target or the service:

systemctl start postgresql