Installing Shaarli on nixOS

Shaarli is a minimalist link sharing service that allows you to save bookmarks to URLs, videos, or images on a self-hosted server. In this tutorial, we will walk through the steps to install Shaarli on nixOS.

Prerequisites

Before we start, make sure you have the following:

Steps

  1. Update your system
sudo nixos-rebuild switch --upgrade
  1. Create a new user for Shaarli
sudo useradd -m -s /bin/bash shaarli
  1. Install PHP
sudo nix-env --install php
  1. Install lighttpd
sudo nix-env --install lighttpd
  1. Clone the Shaarli repository
sudo git clone https://github.com/shaarli/Shaarli.git /var/www/shaarli
  1. Change ownership of the Shaarli repository to the shaarli user
sudo chown -R shaarli:shaarli /var/www/shaarli
  1. Create a lighttpd configuration file for Shaarli
sudo nano /etc/lighttpd/conf.d/shaarli.conf
$HTTP["host"] =~ "shaarli.example.com" {
   server.document-root = "/var/www/shaarli"
   url.rewrite-if-not-file = (
      "^/.(.+)$" => "/index.php?$1"
   )
   fastcgi.server = (".php" =>
      ((
         "socket"   => "/run/php-fpm.sock",
         "bin-path" => "/run/current-system/sw/bin/php-cgi"
      ))
   )
}
  1. Restart lighttpd
sudo systemctl restart lighttpd.service
  1. Access Shaarli on your web browser

You can now access Shaarli by entering the URL http://shaarli.example.com on your web browser. Note that you need to substitute shaarli.example.com with your own domain or IP address.

Conclusion

In this tutorial, we have installed Shaarli, a minimalist link sharing service, on nixOS. By self-hosting Shaarli, you can avoid giving away your browsing data to third-party services and have full control over your bookmarks.

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!