This script doesn't generate a fastfetch config.jsonc from scratch though. Instead it ingeniuosly makes use of a temoplate.json file, meaning a normal config.jsonc without these inserted containers is always used as a base, making this script nondestructive as long as you cp (or mv) the config.jsonc to template.json in the fastfetch config directory.
Edit FastfetchConfDir (if nonstandard) and Array_index. Then rename your config.jsonc to template.json. Finally, add two lines in your sudoers file so you don't need to type your password to run the script (guixcontainersinfo.sh and nsenter).
However you invoke the script, ensure it's ran with sudo. I have an alias for fastfetch in my bashrc which first executes guixcontainersinfo.sh (with sudo) before running fastfetch (&&), then simply add the fastfetch command to the end of my bash_profile.
The reason template.json is important is because it'll serve as the base for constructing the final config.jsonc. Therefore, anything you have in there will never be destroyed (no guarantee, I hold no liability, etc, etc, yada, yada). Treat it as the true config.jsonc. If you at any point don't need this script anymore, you'll still have your basic config.jsonc stored as template.json.
As for the nsenster, even though you run the script with sudo, you'll still need sudo inside the script in order for nsenter to work with you. Below is a sample entry:
- user ALL=NOPASSWD: /run/current-system/profile/bin/nsenter ^[0-9]{4,5}$ hostname