Developing using Arch Linux using Parallels on Apple Silicon with a systemd-nspawn container
/docs/development/setup/alternate/parallels/
Summary of the setup
Note
This setup is for Parallels users on Apple Silicon, such as the newer Macs. It
does not work on x86_64
Macs or PCs.
In brief:
- Download a virtual machine and run it in Parallels. It has all the tools you are going to need pre-installed – build tools, git, IDE etc.
- In the virtual machine, run a single script to customize your setup for different types of things you might want to develop on UBOS.
- UBOS itself runs in a Linux container.
Easy, right?
Prerequisites: install Parallels Desktop for Apple Silicon computers
- This is a paid product that can be obtained from https://www.parallels.com/products/desktop/.
Steps in detail
-
Download the virtual appliance file. To do so, go to https://depot.ubosfiles.net/yellow/aarch64/images/index.html and look for a file whose name starts with
ubosdev
and has extension.pvmp
. If there are several files there with this extension, pick the one that has the most recent timestamp. -
Open the
.pvmp
file with Parallels. Aubosdev
VM will show up in the Parallels Control Center. -
Double-click the VM icon. This will unpack the file into the format that Parallels needs to run it.
-
Right-click the VM icon and select “Configure …”. Make adjustments as needed for your situation, such as how many CPUs the VM may use on your host, and how much memory.
-
Start the VM.
-
If the VM doesn’t open a window on its own, double-click the VM icon.
-
Logon as
ubosdev
, there is no password.root
does not have a password either: we assume that’s safe enough on your computer. If you don’t think so, set one :-) -
Pick a better screen resolution:
- In “Search”, type “Settings” and run it.
- If there’s an error message saying “Network Unavailable” and “Error: NetworkManager not
running”: ignore it, we are not running Network Manager but
systemd-networkd
. - Select “Displays” and pick a resolution that makes sense for your computer setup.
- Close the settings app.
-
In “Search”, type “Console” and run it (you get the “Search” by selecting “Activities” in the menu bar).
-
Update your Arch host to the latest:
% sudo pacman -Syu
If there are a lot of updates (including the kernel, for example), reboot and resume from here after the system has come back up:
% sudo systemctl reboot
-
Set up the UBOS Gears development environment by running:
% ubosdev-container setup
This sets up development on the
yellow
release channel, which is the recommended channel for development.This might take 5-30 min, depending on your network, computer and disk speed.
-
Once this command is complete, you can shutdown the VM any time if you like.
Setting up a container for development
You will perform your actual UBOS development in a Linux container that runs UBOS Linux. In this setup, you can have multiple UBOS Linux container templates, and each of them can be instantiated multiple times.
For example, you might have different container templates for the different UBOS Release Channels. This setup so far has only installed one, which is good enough for most purposes.
To determine which container templates you have available (that depends on the previous step):
% ubosdev-container list-templates
Instantiate one of the available templates into a container to be used for development, such as:
% ubosdev-container create --name ubosdev-yellow --template ubos-develop-yellow
You can instantiate this template multiple times, in case you have multiple workstreams going and want to keep them separate. In this tutorial, we only instantiate one template once.
Ongoing development work
-
Run your Arch Linux development VM in Parallels.
-
To determine which UBOS Linux containers you have:
% ubosdev-container list
-
Inside your Parallels development VM, run your UBOS Linux container:
% ubosdev-container run --name <name>
where
<name>
is the name of an available container, e.g.ubosdev-yellow
.This gives you console access to the container. This command is simply a wrapper around the
systemd-nspawn
command with options that are useful. You could run it directly, too.You shut down the container with 3 quick
^]
s in the primary container console. -
To open up a non-root shell inside your development container, if
ubosdev-yellow
is the name of your container, open a new terminal and execute:% sudo machinectl shell ubosdev@ubosdev-yellow
This essentially does the same thing as if you were to log into your container as user
ubosdev
from the console or viassh
, but you don’t need to have any credentials set up. -
When you run the container with
ubosdev-container run
, your home directory on your Arch Linux host will be the same as the home directory of theubosdev
user in the UBOS Linux container. This makes development much simpler because you can edit files either on the host or in the container; they are the same. -
To edit your code, two IDEs are pre-installed on the Arch Linux host:
geany
is a general-purpose IDE;netbeans
is an IDE particularly suitable for Java development.
Of course, you can install others from the Arch repositories or directly.
-
You can connect to a Site running inside the UBOS Linux development container by using the container’s name as the hostname in the URL. So if one of your running containers is named
ubosdev-yellow
, typinghttp://ubosdev-yellow/
into your browser on the Arch Linux host will talk to the web server in your container. Firefox is pre-installed on the Arch Linux host.