Phone? More like Workstation


20th September 2024

16.4 Minutes

LePichu
Over the past year, I have been primarily using my phone as a Development Environment, giving up not only using my Laptop for a long time, but also a ton of tools and resources that I'd be able to use otherwise, like Copilot, VSCode, IntelliJ, so many tools that I could no longer use, but I prevailed, I ended up figuring out how to program entirely on a phone like a fucking monk or pilgrim of sorts, this is my story, originally I was going to publish this post back in January, but I just decided to finally get around doing it because well, college started, and I need something to vent in, something to keep my sanity in check. So yeah, let's begin!
Through out this tutorial, we will install a shit ton of tools, the kinds of which are listed as follows:
- Terminal (Termux)
- Linux Distribution Environment (Fedora or Void)
- Code Editor (Helix or NeoVim)
- Runtimes, Compilers, and Tools
- VNC, and Wireless Keyboards (Optional)
Before we begin, I am aware a lot of people reading this probably aren't aware of many things, like differences between a Shell and a Terminal. For those people, the simple explanation is that, the shell is the interpreter of the shell language specific to that shell, for example: PowerShell will execute
.ps1
,.psm1
and other related files to it, but something likesh
orbash
will execute POSIX Shell scripts. The Terminal or Terminal Emulator however, will run these shells by providing a Teletyper (TTY) environment, and a GUI for the system it is running on.
Terminal Station: A(ndroid)
For the first step of this "tutorial" of sorts, we need to install Termux, a Terminal Emulator and Teletyper Environment for Android, Termux was at the original time of writing this, no longer available on the Play Store, but they are trying out to get it up there and updated again, that being said, I would still recommend getting it from either F-droid or the GitHub Releases of the termux/termux-app
repository. While this would give you a bare and minimal setup, you can optionally install the Termux:API
and Termux:Styling
packages, Style helps make it more comfy and home-like a lot more, while Termux:API
is optional, I do recommend you install it to get things like Clipboard, TTS, System peripherals like Brightness and more working in programs like Helix and PowerShell, otherwise you cannot sync to your actual Android keyboard or fetch data from it. Lastly, customise to your heart's content by holding down on the screen and then selecting style, if you want that is, we won't judge, but moving on, we now will start with the actual setup.
*Tips Fedora*
For this specific tutorial I'd like to use Fedora, a distribution made by the Fedora Team building on components funded, related, or made by Red Hat and IBM. I however, wrote this section in it's original glory back in January, and personally, I'd like to honour the original write-up in its full-fledged comedic and rage-induced glory. Without further ado– transmission cuts in
For this tutorial specifically, we will be building on top of a Fedora PRoot, there are obviously, other choices like Debian or Void, but over the years Fedora has become the one I most trust when it comes to stability and just working out of the box. First thing you wanna do is install proot-distro
, and then log into it, do so by running the following commands:
$> pkg install proot-distro ... $> proot-distro install fedora ... $> proot-distro login fedora --termux-home # The `--termux-home` flag mounts your $HOME into the PRoot btw [root@localhost ]$
"But Pichu, Why not Arch Linux 1?!?!?!?"
- Some Annoying Fucker on the Internet
SHUT THE FUCK UP, I AM TIRED OF YOU VOCAL MINORITIES, GO BACK TO BEING A FAT ASS BASEMENT DWELLER IN YOUR MOM's BASEMENT WITH NO JOB INSTEAD OF ANNOYING ME. Are they gone yet? Yep, sorry for that outbreak, happens to the best of us 😿 . Oh wait you want Void or Alpine? We can also work with that, the process is pretty similar but unfortunately, you cannot run PowerShell on a Alpine PRoot even with gcompat
, Best bet is to build it yourself manually for this case, anyways instead of fedora
install void
and then log into it, after that the process is practically the same if you're using the tarball version, which we will do here over distro-specific package managers.
$> wget https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/powershell-7.3.6-linux-arm64.tar.gz ... $> mkdir pwsh $> tar -xf ./powershell-7.3.6-linux-arm64.tar.gz -C pwsh ... $> chmod +x ./pwsh/pwsh $> ln -s /data/data/com.termux/files/home/pwsh/pwsh /usr/bin/pwsh ... $> chmod +x /usr/bin/pwsh
With that being said, I might personally look into building PowerShell for ARM64 Alpine myself soon, so you can thank me later.
When you boot up PowerShell for the first time, it can have a number of errors, well, primarily 2 of those that I know of, it either copes about having no icu-libs
being present or CoreCLR cannot be created because your shitty ass phone, mine included, has only 4 fucking GB of RAM or less, and that is a big no-no for CoreCLR. There is a simple fix for that, depending on your distro you just grab the right package, so that would be something like:
# Run xbps-install -u xbps if you haven't used the pkg manager before this command # This is for void btw xbps-install -S icu-libs # This is for Fedora and RHEL-alike dnf install libicu
Transmission cuts off Well, as you can see, that was, well, raw to say the very least. While that was originally written in maybe written in Last December or around Christmas, I have learned how to fix the CoreCLR error now for not just PowerShell, but also everything .NET running under a PRoot or Chroot environment, like the one in Termux. To achieve this, we need to set an Environment Variable specifically, the .NET Heap Limit one, to do so, you can either:
- Overwrite the
.bashrc
to set the context in Bash itself - Or spawn into PowerShell directly and set the variable using the
--env
in theproot-distro
CLI
So that would look something like this:
# Log into the PRoot proot-distro login fedora --termux-home --env DOTNET_GCHeapHardLimit="1C0000000" -- $PWSH_PATH # Or do this in your .bashrc export DOTNET_GCHeapHardLimit="1C0000000"
Well, we have a PRoot now, what next? We should make Termux log into the PRoot on startup, right? Well yes, that is exactly what someone like me does, to do that we need to edit our .bashrc
file, as Termux itself spawns Bash on startup, you can change that, and perhaps you can even write a tiny program to spawn into a PRoot directly, skipping the shell process as a whole, but either way, edit your .bashrc
and add something like the above:
# Note: My PowerShell is stored at $HOME/pwsh # Please do NOT forget to run `chmod +x pwsh` proot-distro login fedora --termux-home --env DOTNET_GCHeapHardLimit="1C0000000" -- $HOME/pwsh/pwsh
Now, every time Termux boots up, you will be logged into the PRoot itself directly.
Invoke-RestMethod "https://gist.githubusercontent.com/LePichu/5c5d43c6c79ed3252883c6e67103564b/raw/8c6040a47818c444f87e912ca6636410882b6eb4/gistfile1.txt" | Set-Content $PROFILE