In fall 2020, I took a course on how to use programming to design and optimize physical products, such as bridges, airplanes, robots and so on. the programming is all done in matlab, so I needed to figure out how to install matlab on my computer. even for most types of linux, this is a pretty easy and well-documented task, but I'm running nixos, which handles packaging, libraries, and filepaths much differently than the standard matlab installer expects.
at this point you might want to say, "hey, you can just use GNU octave or some other free alternative, didn't you know?" and yes, I did consider that; I'm sure the install process would be much, much easier. however, it's required to use matlab rather than some other language, so that's what I'm doing. even with this explanation, I'm sure I'd get "well actually"'d to death by FOSS enthusiasts if I posted this on lobsters or HN or some other garbage forum. /rant
I downloaded the linux installer from the matlab site, and then unzipped it into a directory called installer/. then, I modified a nix derivation that someone on the nixos discourse forum pointed me to. this derivation is basically a recipe to build a bash shell with some specified packages in the environment. crucially, the environment in this shell pretends that the nixos filesystem is one that complies with the FHS (filesystem hierarchy standard), so something like the matlab installer won't get confused. in case it's of any use to you, here's the derivation: (fhs-env.nix).
to actually get the special bash shell, I ran nix-build fhs-env.nix, which created an executable file in result/bin/matlab-env that I then ran to drop into the fake FHS environment.
I was stuck after this for quite a few days, because the default install script (installer/install) always crashed, no matter which of the many solutions from online I applied. eventually, I found a "legacy" install script located at installer/bin/glnxa64/install_unix_legacy, which worked. this script launched a graphical wizard with the standard stuff (verify your account, choose which packages to install, wait twenty minutes or so for all the stuff to download while you're also on a zoom call so your computer's fan is screaming like an eldritch horror awakening from its thousand-year slumber and clambering out of its swampy home on a moonlit night to terrorize the village people). eventually, the installation completed and it was now time to launch the matlab executable.
but wait! this executable didn't work; it segfaulted for some reason. too tired to debug, I decided to look up how to get matlab running without a GUI. it turns out you can run /path/to/matlab -nosplash -nodisplay -nojvm -nodesktop to get a plain repl that doesn't segfault. for reference, I found out how to run matlab without a GUI here, which I'm linking because it's also got other tips and tricks.
as a bonus kludge, I made a script to run matlab with the special shell and special flags and all that, which simplifies things because I don't have to type in such long commands every time I want to run matlab. the code's kinda messy and probably breaks a thousand different best practices, so I won't share it here. basically, it's a shell script file that runs matlab with all the necessary flags, and the shebang line at the top is the path to the FHS shell.