I set up a Debian 12.5 two weeks ago and I took some notes.
After install you'll have to make it possible for yourself to sudo. In terminal use these commands:
su (<enter root password when prompted>)
sudo usermode -aG sudo <your user id here>
then press control-D at the prompt to exit the root shell. Close up terminal and restart.
The sudo should not be necessary on the second line, but I typed it so I included it.
Now after restarting:
sudo apt dist-upgrade
sudo apt install git cmake mold ninja-build
now go to a directory where you want your sources and clone the kicad repo there.
Now install dependencies (these are from the list, this is the list translated to commands):
sudo apt install debhelper doxygen libbz2-dev libcairo2-dev libglu1-mesa-dev
sudo apt install libgl1-mesa-dev libglew-dev libx11-dev libwxgtk3.2-dev
sudo apt install mesa-common-dev pkg-config libssl-dev build-essential cmake-curses-gui debhelper grep
sudo apt install python3-dev swig dblatex po4a asciidoc
sudo apt install python3-wxgtk4.0 libgit2-dev libsecret-1-dev
sudo apt install source-highlight libboost-all-dev libglm-dev libcurl4-openssl-dev
sudo apt install libgtk-3-dev libngspice0-dev ngspice-dev
sudo apt install libocct-modeling-algorithms-dev libocct-modeling-data-dev libocct-data-exchange-dev libocct-visualization-dev libocct-foundation-dev libocct-ocaf-dev
sudo apt install unixodbc-dev libnng-dev libprotobuf-dev protobuf-compiler zlib1g-dev shared-mime-info
sudo apt install python3-pytest python3-cairosvg python3-numpy
finally, you need to have the right items in the path when linking. I never found the right way to do it permanently. So I just enter this command into each terminal at least once before I build:
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
I guess I could put that in my .profile file or something but I never did.
Anyway, that's it. Now you should be able to build using ninja with the steps in the instructions.
You need a 64-bit system I think or the linker will run out of memory. And you need a fair bit of swap space. By a fair bit, I mean more than my "toy" install I tried to make had. The default install of Debian seems to have enough when I install it.
The instructions say to use Debian because Ubuntu will make the app mess up. I think this is because of Wayland. Well, both of them use Wayland now so I think you can just use Ubuntu if you want. Someone else suggested Mint. I dunno, the instructions above are for Debian 12.5.
Good luck.