optimal setting for make -j

Actually, nproc is not a variable, it’s a command. The $(command) syntax of bash is called command substitution. The string "$(nproc)" makes bash execute the command nproc and then replace the string with its output.