Libravatar is a service that provides a free and open-source distributed avatar hosting service. It provides an email-based avatar mapping to provide users with a consistent avatar across different websites. In this tutorial, we will learn how to install Libravatar on NixOS Latest.
Before we get started with the installation of Libravatar, there are a few things we need to have in place. These include:
The first step is to install the required packages for hosting Libravatar. We can do this by adding the following code snippet to the environment.systemPackages
in /etc/nixos/configuration.nix
file.
environment.systemPackages = with pkgs; [
libravatar
mariadb
mariadb-clients
];
After adding the code snippet to the file, we need to run sudo nixos-rebuild switch
to update the system environment.
Libravatar requires a database to store its data. We will use MariaDB for this purpose. The first step is to create a database and user for Libravatar. We can do this using the following commands:
$ sudo mysql -u root
> CREATE DATABASE libravatar;
> CREATE USER 'libravatar'@'localhost' IDENTIFIED BY 'yourpassword';
> GRANT ALL PRIVILEGES ON libravatar.* TO 'libravatar'@'localhost';
> FLUSH PRIVILEGES;
> exit
Next, we need to update the /etc/libravatar.conf
file with database details:
[database]
database = libravatar
user = libravatar
password = yourpassword
The next step is to configure DNS records for Libravatar. We will create two subdomains, www
and lbv
, for Libravatar. We also need to create an A record pointing to the IP address of our server. We can do this by adding the following code snippet to the networking.firewall.allowedTCPPorts
section in /etc/nixos/configuration.nix
:
networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.enable = true;
networking.firewall.allowPing = true;
networking.hostName = "your_domain_name.tld";
networking.firewall.extraCommands = ''
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --zone=public --add-service=https --permanent
firewall-cmd --reload
'';
Next, we need to configure Nginx as a reverse proxy for Libravatar. We can do this by adding the following code snippet to the /etc/nixos/configuration.nix
file:
nginx = {
domain = "your_domain_name.tld";
enable = true;
forceSSL = true;
httpConfig = ''
server {
listen 80;
server_name www.${nginx.domain};
return 301 https://$server_name$request_uri;
}
server {
listen 80;
server_name lbv.${nginx.domain};
location / {
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
'';
};
After adding the code snippet to the file, we need to run sudo nixos-rebuild switch
to update the system environment.
Finally, we can start the Libravatar service using the following command:
$ sudo systemctl start libravatar
We can verify that the service is running by checking its status:
$ sudo systemctl status libravatar
In this tutorial, we have learned how to install Libravatar on NixOS Latest. We installed the required packages, configured MariaDB database, created domains and added DNS records. We also configured Nginx as a reverse proxy and started the Libravatar service. With Libravatar up and running, users can now have a consistent avatar across different websites.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!