aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2022-12-10-alpine-setup.md
blob: 1fa9027833b2d0631f77141e7adf7fd54de9a44b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
---
title: "Alpine set up for daily driver"
date: 2022-12-10
tags: ['alpine', 'linux']
---

## Disable secure boot

First, always check for secure book. If it is enabled you won't be able to boot
your thumbdrive.

## setup-alpine
On the official wiki[^1] there a more complete guide on how to setup, and will
probably be more accurate than this one, so always refer to that wiki first.
This is more a log of how I setup. 

Once you boot your live installation run `setup-alpine` and follow the steps:

* _Select keyboard layout_: **us**

* _Select keyboard variant_: **us**

* _Enter system hostname_: **gridx.local** [This is my choice, if you don't know
  what exactly is this go for the default **localhost**]

* _Which one do you want to initialize?_: **wlan0** [I chose wlan0, since it is
  a laptop I don't have it connected to cable]

* _Type the wireless network name to connect to_: **\<NAME\>**

* _Type network key_: ******

* _Ip address for wlan0_? **dhcp** [and for the following device I have chose
  none since I won't use them anyways]

* _Do you want to do any manual network configuration_? **n** 

* _Changing password for root_: ******

* _Which timezone are you in?_ **Europe/Berlin**

* _HTTP/FTP proxy URL?_ **none**

* _Which NTP client to run?_ **busybox** [I don't have a good experience with
  chrony, busybox works better for me]

* _Enter mirro number?_ **f** [I pick this one to speed up things a bit, default
  one is fine as well]

* _Set an user?_ **\<NAME\>** [Since we aiming to be a desktop create your user here]

* _Full name for user \<NAME\>:_ **\<FULLNAME\>**
* _Type password_: ******

* _Enter ssh key or URL for \<NAME\>?_ **none** [this is a public key so you can
  ssh into this machine]

* _Which ssh server?_ **openssh**

* _Which disks would like to use?_ **\<DISK\>** [now you are going to set up the
  disk for installation]

* _How would you like to use it?_ **crypt** [I like to use encrypted disks, I
  strongly advice for it, but in case you don't want, go for sys directly]

* _How would you like to use it?_ **lvm**

* _How would you like to use it?_ **sys** [more info[^2]]

* _WARNING: Erase the above disks and continue?_ **y**

* Enter passphrase for \<DISK\>: ******

Once you have finish the step run `reboot`.

## Desktop environment

Now comes the "hard" part, where we need to configure the desktop. For me, I'm
going for i3wm with lightdm.

To be able to install all the necessary packages we will need to enable the
community repository[^3]. To edit it I use vim

```bash
apk add vim
# then
vim /etc/apk/repositories
```
and uncomment the `.../community`

```bash
#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.16/main
http://dl-cdn.alpinelinux.org/alpine/v3.16/community
#http://dl-cdn.alpinelinux.org/alpine/edge/main
#http://dl-cdn.alpinelinux.org/alpine/edge/community
#http://dl-cdn.alpinelinux.org/alpine/edge/testing
```

Then run  `apk update` and you will see the both repositories printed out.

Now we will install the necessary drivers for `xorg` to run properly. Firs
search for all  video drivers `apk search xf86-video*` and install whatever you
have for you computer (in my case `apk add apk add xf86-video-amdgpu`)

Add required mesa drivers:

```bash
apk add mesa-dri-gallium mesa-va-gallium mesa-egl
```

Alpine provides a command to install required packages for xorg 

```bash
setup-xorg-base
```

Now to set the `lightdm` and its required dbus setup:

```bash
apk add lightdm-gtk-greeter
setup-devd udev
rc-update add dbus boot
rc-update add lightdm boot
apk add terminus-font
dbus-uuidgen > /var/lib/dbus/machine-id
rc-update add dbus
```

Now for the i3wm:

```bash
apk add i3wm i3status xterm i3lock
add user <NAME> input`
add user <NAME> video`
```

## Networking

It uses `networking` by default, which I don't like very much, so let's switch
to `NetworkManager`[^6].

First install it and its requirement:

```bash
apk add networkmanager networkmanager-wifi # for wifi support
```

Add user to group:

```bash
adduser <USER> plugdev
```

And as every group change you will have to logout and login again to those
changes take effect.

Now let's edit its configuration on `/etc/NetworkManager/NetworkManager.conf`

```bash
[main] 
dhcp=internal
plugins=ifupdown,keyfile

[ifupdown]
managed=true
```


Now, we need to swap services:

```bash
rc-service networking stop          # stop networking service
rc-update del networking boot       # remove it from start up from boot level

rc-service networkmanager start     # start networkmanager service
rc-update add networkmanager boot   # add it from start up on boot level
```

Also, install `np-applet`[^7] for desktop tray icon

```bash
apk add network-manager-applet 
```

### WIFI
By default if it will setup `wpa_supplicant`[^5] for WIFI, but I opted for
`iwd`[^8].

```bash
apk add iwd
```

Now append to the `/etc/NetworkManager/NetworkManager.conf`:

```bash
# ...
[device]
wifi.backend=iwd
```

Swap WIFI services:

```bash
rc-service wpa_supplicant stop          # stop wpa_supplicant service
rc-update service del wpa_supplicant    # remove it from start up 

rc-service iwd start                    # start iwd service
rc-update service add iwd               # add it to start up
```

## Extras 

There is a list go command that I use that may be helpful:

``` bash
apk add perl bash fzf           # required for things to work
apk add fish                    # shell
apk add zathura-pdf-poppler     # pdf viewer
apk add ranger                  # file explorer
apk add alpine-sdk make git go  # some dev tooling
apk add qutebrowser             # browser
apk add keepassxc               # password manager
apk add aerc                    # mail
```

## Wiki

There is a more complete from the alpine wiki[^4], which will give more context
to the commands.

[^1]: https://wiki.alpinelinux.org/wiki/Installation#Questions_asked_by_setup-alpine
[^2]: https://wiki.alpinelinux.org/wiki/Installation#The_general_course_of_action
[^3]: https://wiki.alpinelinux.org/wiki/Repositories#Enabling_the_community_repository
[^4]: https://wiki.alpinelinux.org/wiki/Setting_up_a_laptop
[^5]: https://wiki.alpinelinux.org/wiki/Wi-Fi
[^6]: https://wiki.alpinelinux.org/wiki/NetworkManager
[^7]: https://pkgs.alpinelinux.org/packages?name=network-manager-applet&branch=edge&repo=&arch=x86_64&maintainer=
[^8]: https://wiki.archlinux.org/title/Iwd