I am using Artix with Runit. There seems to be a discrepancy between Arch and Artix assumptions about data locations for PostgreSQL.
1) If you follow the Arch Linux Wiki https://wiki.archlinux.org/index.php/PostgreSQL there is this command:
[postgres]$ initdb -D /var/lib/postgres/data
which assumes /var/lib/postgres/data as data location.
However Artix Linux postgresql-runit package assumes /var/lib/postgresql/data location.
2) /etc/runit/sv/postgresql/log/run uses logger:
#!/bin/sh
exec logger -p daemon.info -t postgres
which for some reason does not log anywhere on my system:
$ ls /var/log
btmp dmesg.log pacman.log tallylog wtmp
so in /var/log I created folder:
drwxr-x--- root wheel sv
and in /var/log/sv folder:
drwxr-x--- root wheel postgresql
and changed /etc/runit/sv/postgresql/log/run to
#!/bin/sh
exec svlogd /var/log/sv/postgresql
svlogd is a runit logger that is installed on Artix Linux by default, so why not use it?
3) From produced logs I uncovered another problem - PostgreSQL cannot create socket file in /run/postgresql/ because the folder does not exist.
As I understand /run is in memory, not on disk, so it makes no sense to create it manually adhoc - it has to be created on every boot. This highlights the reason why the following message appears after postgresql installation and then on every boot:
chattr: Operation not supported while setting flags on /var/lib/postgres/data
Specifically, /etc/rc/sysinit/75-tmpfiles-setup is failing.
It uses /usr/lib/tmpfiles.d/postgresql.conf to ensure needed folders are created.
$ pacman -Qo /usr/lib/tmpfiles.d/postgresql.conf
/usr/lib/tmpfiles.d/postgresql.conf is owned by postgresql 12.2-1
$ cat /usr/lib/tmpfiles.d/postgresql.conf
d /var/lib/postgres/data 700 postgres postgres
h /var/lib/postgres/data - - - - +C
h ... +C disables copy-on-write on those file systems which support this feature (ex., btrfs).
This operation is not supported on ext4, so I removed the line, and hence the error message.
This file again assumes /var/lib/postgres/data data location, which is /var/lib/postgresql/data on Artix.
So the final version of /usr/lib/tmpfiles.d/postgresql.conf is:
d /var/lib/postgresql/data 700 postgres postgres
in addition I created /etc/tmpfiles.d/postgresql.conf:
d /run/postgresql 770 postgres postgres
4) Ensure your user account is in the postgres group:
$ groups
postgres wheel {username}
If not:
# usermod -a -G postgres {username}
After that reenter your login shell.
Also check the postgres user in the /etc/passwd file for correct path to its home folder: /var/lib/postgresql.
5) Uncomment in /var/lib/postgresql/data/postgresql.conf:
listen_addresses = 'localhost'
6) /etc/hosts should contain at least:
127.0.0.1 localhost
::1 localhost
127.0.1.1 myhostname.localdomain myhostname
https://wiki.archlinux.org/index.php/Installation_guide#Network_configuration
Now I have a working PostgreSQL installation.