How can I save and export the settings letting apps be attached to workspaces?

In macOS, it is easy to assign an app to a workspace so that every time the app is launched it is automatically opening in the designated workspace.

Where is that information stored

That information is stored in:

~/Library/Preferences/com.apple.spaces.plist

Under the app-bindings key.

In Terminal you can use:

defaults read com.apple.spaces.plist app-bindings

To see what application are bound to a particular Desktop/Space.

As an example, here is a snippet from the command above:

 % defaults read com.apple.spaces.plist app-bindings
{
    "org.videolan.vlc" = "F124EFFD-7A6E-4B41-851E-2DD708E826E8";
}
%

Where F124EFFD-7A6E-4B41-851E-2DD708E826E8 is the UUID of my second Desktop/Space and this Information is elsewhere in the .plist file.


so that I could make it part of my config files that I install on any macOS that I use (instead of having to manually reassign apps each time)?

The UUID of a Desktop/Space is going to be unique from one Mac to another, so while one can get the information from the com.apple.spaces.plist file, nonetheless, one would have to write a script that with get the UUID of each Desktop/Space on that different Mac and apply it to the application's Bundle ID in the app-bindings key.

You will also have issues with how to get the updated information on the different Mac to take effect, but lets say that's outside the scope of the question asked.


Notes:

.plist files are XML Property Lists, however, some are in binary format.

You can use the plutil command to convert a copy of the target file to ASCII XML.

See the manual pages for both plutil and defaults.

You can read the manual page for command in Terminal by typing man command, then press enter, or for easier reading, just type command and then right-click on it and select: Open man Page

There is also /usr/libexec/PlistBuddy that can work with .plist files.