gabrielgio.me @ 6eb1360f4a8362fd32db156b60281c99aae2c7c1

  1---
  2title: "Alpine set up for daily driver"
  3date: 2022-12-10
  4tags: ['alpine', 'linux']
  5---
  6
  7## Disable secure boot
  8
  9First, always check for secure book. If it is enabled you won't be able to boot
 10your thumbdrive.
 11
 12## setup-alpine
 13On the official wiki[^1] there a more complete guide on how to setup, and will
 14probably be more accurate than this one, so always refer to that wiki first.
 15This is more a log of how I setup. 
 16
 17Once you boot your live installation run `setup-alpine` and follow the steps:
 18
 19* _Select keyboard layout_: **us**
 20
 21* _Select keyboard variant_: **us**
 22
 23* _Enter system hostname_: **gridx.local** [This is my choice, if you don't know
 24  what exactly is this go for the default **localhost**]
 25
 26* _Which one do you want to initialize?_: **wlan0** [I chose wlan0, since it is
 27  a laptop I don't have it connected to cable]
 28
 29* _Type the wireless network name to connect to_: **\<NAME\>**
 30
 31* _Type network key_: ******
 32
 33* _Ip address for wlan0_? **dhcp** [and for the following device I have chose
 34  none since I won't use them anyways]
 35
 36* _Do you want to do any manual network configuration_? **n** 
 37
 38* _Changing password for root_: ******
 39
 40* _Which timezone are you in?_ **Europe/Berlin**
 41
 42* _HTTP/FTP proxy URL?_ **none**
 43
 44* _Which NTP client to run?_ **busybox** [I don't have a good experience with
 45  chrony, busybox works better for me]
 46
 47* _Enter mirro number?_ **f** [I pick this one to speed up things a bit, default
 48  one is fine as well]
 49
 50* _Set an user?_ **\<NAME\>** [Since we aiming to be a desktop create your user here]
 51
 52* _Full name for user \<NAME\>:_ **\<FULLNAME\>**
 53* _Type password_: ******
 54
 55* _Enter ssh key or URL for \<NAME\>?_ **none** [this is a public key so you can
 56  ssh into this machine]
 57
 58* _Which ssh server?_ **openssh**
 59
 60* _Which disks would like to use?_ **\<DISK\>** [now you are going to set up the
 61  disk for installation]
 62
 63* _How would you like to use it?_ **crypt** [I like to use encrypted disks, I
 64  strongly advice for it, but in case you don't want, go for sys directly]
 65
 66* _How would you like to use it?_ **lvm**
 67
 68* _How would you like to use it?_ **sys** [more info[^2]]
 69
 70* _WARNING: Erase the above disks and continue?_ **y**
 71
 72* Enter passphrase for \<DISK\>: ******
 73
 74Once you have finish the step run `reboot`.
 75
 76## Desktop environment
 77
 78Now comes the "hard" part, where we need to configure the desktop. For me, I'm
 79going for i3wm with lightdm.
 80
 81To be able to install all the necessary packages we will need to enable the
 82community repository[^3]. To edit it I use vim
 83
 84```bash
 85apk add vim
 86# then
 87vim /etc/apk/repositories
 88```
 89and uncomment the `.../community`
 90
 91```bash
 92#/media/cdrom/apks
 93http://dl-cdn.alpinelinux.org/alpine/v3.16/main
 94http://dl-cdn.alpinelinux.org/alpine/v3.16/community
 95#http://dl-cdn.alpinelinux.org/alpine/edge/main
 96#http://dl-cdn.alpinelinux.org/alpine/edge/community
 97#http://dl-cdn.alpinelinux.org/alpine/edge/testing
 98```
 99
100Then run  `apk update` and you will see the both repositories printed out.
101
102Now we will install the necessary drivers for xorg to run properly. Firs
103search for all  video drivers `apk search xf86-video*` and install whatever you
104have for you computer (in my case `apk add apk add xf86-video-amdgpu`)
105
106Add required mesa drivers:
107
108```bash
109apk add mesa-dri-gallium mesa-va-gallium mesa-egl
110```
111
112Alpine provides a command to install required packages for xorg 
113
114```bash
115setup-xorg-base
116```
117
118Now to set the `lightdm` and its required dbus setup:
119
120```bash
121apk add lightdm-gtk-greeter
122setup-devd udev
123rc-update add dbus boot
124rc-update add lightdm boot
125apk add terminus-font
126dbus-uuidgen > /var/lib/dbus/machine-id
127rc-update add dbus
128```
129
130Now for the i3wm:
131
132```bash
133apk add i3wm i3status xterm i3lock
134add user <NAME> input`
135add user <NAME> video`
136```
137
138## Networking
139
140It uses `networking` by default, which I don't like very much, so let's switch
141to `NetworkManager`[^6].
142
143First install it and its requirement:
144
145```bash
146apk add networkmanager networkmanager-wifi # for wifi support
147```
148
149Add user to group:
150
151```bash
152adduser <USER> plugdev
153```
154
155And as every group change you will have to logout and login again to those
156changes take effect.
157
158Now let's edit its configuration on `/etc/NetworkManager/NetworkManager.conf`
159
160```bash
161[main] 
162dhcp=internal
163plugins=ifupdown,keyfile
164
165[ifupdown]
166managed=true
167```
168
169
170Now, we need to swap services:
171
172```bash
173rc-service networking stop          # stop networking service
174rc-update del networking boot       # remove it from start up from boot level
175
176rc-service networkmanager start     # start networkmanager service
177rc-update add networkmanager boot   # add it from start up on boot level
178```
179
180Also, install `np-applet`[^7] for desktop tray icon
181
182```bash
183apk add network-manager-applet 
184```
185
186### WIFI
187By default if it will setup `wpa_supplicant`[^5] for WIFI, but I opted for
188`iwd`[^8].
189
190```bash
191apk add iwd
192```
193
194Now append to the `/etc/NetworkManager/NetworkManager.conf`:
195
196```bash
197# ...
198[device]
199wifi.backend=iwd
200```
201
202Swap WIFI services:
203
204```bash
205rc-service wpa_supplicant stop          # stop wpa_supplicant service
206rc-update service del wpa_supplicant    # remove it from start up 
207
208rc-service iwd start                    # start iwd service
209rc-update service add iwd               # add it to start up
210```
211
212## Extras 
213
214There is a list go command that I use that may be helpful:
215
216``` bash
217apk add perl bash fzf           # required for things to work
218apk add fish                    # shell
219apk add zathura-pdf-poppler     # pdf viewer
220apk add ranger                  # file explorer
221apk add alpine-sdk make git go  # some dev tooling
222apk add qutebrowser             # browser
223apk add keepassxc               # password manager
224apk add aerc                    # mail
225```
226
227## Wiki
228
229There is a more complete from the alpine wiki[^4], which will give more context
230to the commands.
231
232[^1]: https://wiki.alpinelinux.org/wiki/Installation#Questions_asked_by_setup-alpine
233[^2]: https://wiki.alpinelinux.org/wiki/Installation#The_general_course_of_action
234[^3]: https://wiki.alpinelinux.org/wiki/Repositories#Enabling_the_community_repository
235[^4]: https://wiki.alpinelinux.org/wiki/Setting_up_a_laptop
236[^5]: https://wiki.alpinelinux.org/wiki/Wi-Fi
237[^6]: https://wiki.alpinelinux.org/wiki/NetworkManager
238[^7]: https://pkgs.alpinelinux.org/packages?name=network-manager-applet&branch=edge&repo=&arch=x86_64&maintainer=
239[^8]: https://wiki.archlinux.org/title/Iwd