Adding custom dictionaries to a postrgresql install

Hi, I’ve been having some trouble adding custom dicts to a postgresql install, specifically when using plugins (eg. postgis).

I left off some time ago with this overlay:

      overlay =
        (final: prev: {
          #...

          postgresql_17 = let
            pkg = prev.postgresql_17.withPackages (ext: [
              ext.postgis
            ]);
          in
            pkg.overrideAttrs (oldAttrs: {
                postInstall = ''
                mkdir -p $out/share/postgresql/tsearch_data
                  cp ${./dictionaries}/sv_se.affix $out/share/postgresql/tsearch_data/
                  cp ${./dictionaries}/sv_se.dict $out/share/postgresql/tsearch_data/
                '';
            });
        });

Which I then use in a devenv devShell:

      devShells = forEachSystem
        (system:
          let
            pkgs = import nixpkgs {
              inherit system;
              overlays = [ overlay ];
            };

          in
            {
            default = devenv.lib.mkShell {
              inherit inputs pkgs;
              modules = [
                {
                  # ...
                  services.postgres = {
                    enable = true;

                    package = pkgs.postgresql_17;

                    #...
                  };

                }
              ];
            };
          });

What’s odd is that whenever I don’t use any plugins, this works just fine and the new sv dicts could be found where they’re expected to be. However, when adding the postgis extension (whether directly to a package like above, or via devenv) this is not the case and the default package with the extension is used instead of rebuilding with the new dicts.

I’m relatively unfamiliar with nix, so maybe there’s some quirks I’m missing.

Cheers.