nosada / mkosi-files

Configs and files for creating basic Arch Linux container image on systemd-nspawn using mkosi
Do What The F*ck You Want To Public License
6 stars 0 forks source link
archlinux mkosi nspawn

What's this

Mkosi configs and files for Arch Linux systemd-nspawn images.

Expected to be used in Arch Linux box.

How to use

  1. Install base-devel, git
  2. Install mkosi (or mkosi-git in AUR)
  3. Clone this repository

After cloning it, you can do the followings:

Simple way

Run update-nspawn-images as root:

update-nspawn-images CONTAINER [OTHER_CONTAINER ...]

where CONTAINER or OTHER_CONTAINER are nspawn container name in this repository.

update-nspawn-images will do below:

  1. Build specified nspawn image
  2. Remove existing image (nspawn container will be terminated)
  3. Install new image and config

Complicated way

Create container image

cd CONTAINER/
sudo make

Import built image

cd CONTAINER/
sudo make install

Remove container image

cd CONTAINER/
sudo make uninstall

Clean built files

Delete container image and mkosi.default in CONTAINER/

cd CONTAINER/
sudo make clean

Containers on this repository

Notes

Communicating outside container with VirtualEthernet=yes

See this comment.

Using guispawn

Some environment variables are required to run X apps. Use below snippet:

machinectl shell \
    --setenv=display=:0 \
    --setenv=xauthority="\${HOME}/.xauthority" \
    --setenv=pulse_server=unix:/run/user/host/pulse/native \
    gui@guispawn /usr/bin/COMMAND ARGUMENTS

Or you can use script launch-app-in-container like below:

launch-app-in-container COMMAND ARGUMENTS

This will do same thing of above snippet.