archbox/README.md

151 lines
6.0 KiB
Markdown
Raw Normal View History

2020-10-28 03:17:12 +00:00
# Archbox
2020-10-28 03:54:45 +00:00
Installs Arch Linux inside a chroot enviroment.
2020-10-28 03:17:12 +00:00
## Why?
2020-10-29 05:16:49 +00:00
Ever since I'm running some niche distros like Void, Solus, I had a problem finding softwares I need in their not-so-large repositories, also I don't like how flatpak and snap works. so i decided to create an Arch Linux chroot enviroment everytime I distrohop. Why Arch Linux? They have a really, really good repositories, oh and don't mention how big AUR is.
2020-10-28 03:54:45 +00:00
## Installation
2020-11-17 18:14:00 +00:00
### Dependencies
- Bash
- Sed
- Wget
- Tar
2020-12-29 11:44:40 +00:00
- Desktop-file-utils
2020-12-15 07:14:52 +00:00
- Zenity (Optional: for .desktop entry manager GUI)
2020-10-28 03:54:45 +00:00
### Installing Archbox
It's pretty easy, just run ```install.sh``` as root.
### Installing chroot enviroment
2020-11-18 08:26:24 +00:00
Before creating chroot enviroment, edit your chroot username in ```/etc/archbox.conf```, then do :
2020-10-29 05:16:49 +00:00
```
sudo archbox --create <archlinux tarball download link>
```
2020-11-09 14:16:29 +00:00
### Configuring filesystem automount
2020-11-17 18:07:02 +00:00
Execute ```/usr/local/share/archbox/bin/archboxinit start``` on boot.
If you use systemd, you can create a systemd service with this syntax below :
```
[Unit]
Description=Archbox init
PartOf=multi-user.target
[Service]
ExecStart=/usr/local/share/archbox/bin/archboxinit start
Type=oneshot
User=root
[Install]
WantedBy=multi-user.target
```
Thanks to [@SamsiFPV](https://github.com/SamsiFPV)
If you don't use systemd, either create your own init service, or create a @reboot cronjob.
2020-11-02 03:00:22 +00:00
### Removing chroot enviroment
**IMPORTANT**, Make sure you've unmounted everything in chroot enviroment, if you're unsure which partitions must be unmounted, remove the init script and reboot, then delete the folder.
2020-10-28 03:54:45 +00:00
### Entering chroot enviroment
2020-10-29 05:16:49 +00:00
To enter chroot, do :
```
archbox --enter
```
2020-10-28 03:54:45 +00:00
### Executing commands in chroot enviroment
2020-10-29 05:16:49 +00:00
To execute commands inside chroot envirotment, do :
```
archbox <command>
```
for example, to update chroot, do :
```
archbox sudo pacman -Syu
```
2020-10-28 03:17:12 +00:00
### Optional steps
2020-11-01 09:36:27 +00:00
You may want to add this if you don't want to run archbox chroot without password :
2020-10-28 03:17:12 +00:00
#### Sudo
2020-10-29 05:16:49 +00:00
```
%wheel ALL=(root) NOPASSWD: /usr/local/share/archbox/bin/archbox,/usr/local/share/archbox/bin/copyresolv,/usr/local/share/archbox/bin/remount_run
2020-10-29 05:16:49 +00:00
```
2020-10-28 03:17:12 +00:00
#### Doas
2020-10-29 05:16:49 +00:00
```
2020-11-15 05:33:43 +00:00
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/archbox
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/copyresolv
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/remount_run
2020-10-29 05:16:49 +00:00
```
2020-10-28 03:54:45 +00:00
### Misc
2020-11-09 14:16:29 +00:00
#### Systemd services
Use ```servicectl``` command to manage systemd services.
2020-11-10 04:16:25 +00:00
More info [here](https://github.com/smaknsk/servicectl)
To enable service on host boot, in archbox do :
```
sudo servicectl enable <service name>
```
To start services immediately, in archbox do :
```
sudo servicectl start <service name>
```
2020-12-15 07:37:51 +00:00
This isn't actually using systemd to start services, rather it parses systemd .service files and executes it.
#### Desktop entries
Use ```archbox-desktop``` to install desktop entries in chroot to host (installed to ```~/.local/share/applications/archbox```)
2020-10-28 03:54:45 +00:00
#### Lauching apps via rofi
2020-12-15 07:37:51 +00:00
Instead of opening terminal or installing desktop entries everytime you want to run application inside chroot, you may want to launch rofi inside chroot, install rofi and do :
2020-10-29 05:16:49 +00:00
```
2020-11-09 14:16:29 +00:00
archbox rofi -show drun
2020-10-29 05:16:49 +00:00
```
2020-10-28 16:06:06 +00:00
#### Prompt
2020-10-29 17:29:44 +00:00
If you use bash with nerd font you could add a nice little Arch Linux icon in your prompt, add :
2020-10-29 05:16:49 +00:00
```
[[ -e /etc/arch-release ]] && export PS1=" $PS1"
```
to your ```~/.bashrc```
2020-10-29 06:11:29 +00:00
#### Adding enviroment variables
2020-10-29 06:12:09 +00:00
Edit ENV_VAR in ```/etc/archbox.conf```. For example, if you want to use qt5ct as Qt5 theme, edit it like this :
2020-10-29 06:11:29 +00:00
```
ENV_VAR="QT_QPA_PLATFORMTHEME=qt5ct"
```
2020-10-29 17:29:44 +00:00
An example with multiple enviroment variables.
```
ENV_VAR="QT_QPA_PLATFORMTHEME=qt5ct GTK_CSD=0 LD_PRELOAD=/var/home/lemniskett/git_repo/gtk3-nocsd/libgtk3-nocsd.so.0"
```
2020-11-02 10:01:55 +00:00
### Known issues
2020-12-28 12:25:59 +00:00
#### NixOS-specific issues
2021-01-10 08:22:02 +00:00
##### /run mounting
2020-12-28 12:25:59 +00:00
Mounting ```/run``` somehow breaks NixOS, set ```MOUNT_RUN``` in ```/etc/archbox.conf``` to anything other than ```yes``` to disable mounting ```/run```, then do :
```
archbox --mount-runtime-only
```
after user login to make XDG runtime directory accessible to chroot enviroment. make sure dbus unix:path is in XDG runtime directory too.
```
$ echo $XDG_RUNTIME_DIR
/run/user/1000
$ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/run/user/1000/bus
```
2021-01-04 05:08:39 +00:00
Or alternatively if you use WM-only, just disable mounting ```/run``` entirely and manually set XDG_RUNTIME_DIR into ```/tmp``` like ```/tmp/$(whoami)```.
2021-01-10 08:22:02 +00:00
##### Archbox doesn't access resources in /usr/share
In Archbox, Symlink ```/usr``` to ```/run/current-system/sw```:
```
sudo mkdir -o /run/current-system/
sudo ln -s /usr /run/current-system/sw
```
make sure /run isn't mounted.
2020-11-25 12:32:58 +00:00
#### PulseAudio refused to connect
This can be caused by different dbus machine-id between chroot and host, copying ```/etc/machine-id``` from host to chroot should do the job.
#### Musl-based distros
2020-11-02 10:01:55 +00:00
Although /run is mounted in chroot enviroment on boot, XDG_RUNTIME_DIR is not visible in chroot enviroment, remounting /run will make it visible. do :
```
archbox --remount-run
```
2020-12-11 19:04:08 +00:00
after user login, Also if you use Void Musl, you need to kill every process that runs in XDG_RUNTIME_DIR when you log out, You need to reinstall archbox with ```--exp``` flag and use ```startx-killxdg``` instead of ```startx```, or run :
```
/usr/local/share/archbox/bin/remount_run killxdg
```
on logout. you can put it in ```/etc/gdm/PostSession/Default``` if you use GDM
2020-11-12 10:06:20 +00:00
Tested in Void Linux musl and Alpine Linux.
2020-11-12 15:20:54 +00:00
#### Polkit
```pkexec``` is kind of tricky to make it work in chroot, if you use rofi to launch GUI applications in chroot, you may not able to launch any ```.desktop``` files with ```Exec=pkexec...``` in it. If you really want them to work, you can do :
```
2020-11-13 05:00:16 +00:00
sudo ln -sf /usr/bin/sudo /usr/bin/pkexec
2020-11-12 15:20:54 +00:00
```
in chroot and prevent pacman from restoring ```/usr/bin/pkexec``` by editing ```NoExtract``` in ```/etc/pacman.conf```.
#### No sudo password in chroot by default.
You could use ```sudo``` in archbox, but you'll have no way to enter the password when doing e.g. ```archbox sudo pacman -Syu```. also you could enter the password if you do ```archbox -e < <(echo $COMMAND)```, but that would disable stdin entirely during $COMMAND.