How to install Baïkal on NixOS Latest?

Baïkal is a lightweight CalDAV and CardDAV server, built on top of the SabreDAV framework. It allows you to synchronize your calendar and contacts with your mobile devices, desktop applications, and web-based clients. In this tutorial, we will learn how to install Baïkal on NixOS Latest.

Prerequisites

Before we begin, you need to have:

Steps

  1. Update the system

    Use the following command to update your system to the latest packages:

    sudo nixos-rebuild switch
    
  2. Create a new user

    You should create a new Unix user that will run the Baïkal server. Choose a name for the user, replace bailkal in the following commands with your preferred username.

    sudo useradd -m -s /bin/bash baikal
    sudo passwd baikal
    su - baikal
    
  3. Install the required dependencies

    Install the required packages:

    nix-env -iA nixos.php
    

    Baïkal also requires SQLite and PDO, which are enabled by default in the PHP package.

  4. Download Baïkal

    Use the following commands to download the latest version of Baïkal into the user's home directory:

    cd ~/
    mkdir baikal
    cd baikal
    wget https://github.com/sabre-io/Baikal/releases/download/0.7.2/baikal-0.7.2.zip
    unzip baikal-0.7.2.zip
    

    Note: If you prefer a different version, please check the releases page on GitHub.

  5. Configure Baïkal

    Use the following command to create a new configuration file:

    cp ~/baikal/Specific/config/SQLite.example.php ~/baikal/Specific/config/SQLite.php
    

    Edit the configuration file:

    nano ~/baikal/Specific/config/SQLite.php
    

    Replace the database settings with the following:

    'pdo' => [
        'dsn' => 'sqlite:/home/baikal/baikal/Specific/db/db.sqlite',
        'username' => null,
        'password' => null,
    ],
    
  6. Set up the HTTP server

    In this tutorial, we will use the Nginx HTTP server. Add the following code to the /etc/nixos/configuration.nix file:

    services.nginx = {
      enable = true;
      recommendedTlsSettings = true;
      virtualHosts."yourdomain.com" = {
        locations."/baikal" = {
          root = "/home/baikal/baikal";
          index = "Core/admin/index.php";
          tryFiles = [ "$uri" "$uri/ /baikal/Core/admin/index.php?$args" ];
          fastcgiPass = "unix:/run/php-fpm/php-fpm.sock";
          fastcgiParams = {
            SCRIPT_FILENAME = "/home/baikal/baikal/Core/admin/index.php";
            SCRIPT_NAME = "/baikal/Core/admin/index.php";
            DOCUMENT_ROOT = "/home/baikal/baikal";
          };
          errorPage404 = "/baikal/Core/admin/index.php";
        };
      };
    };
    

    Replace yourdomain.com with your own domain name or IP address.

    Save the file and use the following command to reload the configuration:

    sudo nixos-rebuild switch
    

    This will install the Nginx service with the recommended TLS settings, add a virtual host for your domain, and configure the Baïkal location.

  7. Start the PHP service

    Use the following command to start the PHP FastCGI Process Manager (PHP-FPM) service:

    sudo systemctl start php-fpm
    sudo systemctl enable php-fpm
    
  8. Start the Baïkal server

    Use the following command to start the Baïkal server:

    cd ~/baikal
    php Core/bin/cal.php
    

    You should see the following output:

    Starting caldav system...
    The caldav system is now running.
    

    Note: If you want to stop the server, press Ctrl+C.

  9. Open the Baïkal web interface

    Open your web browser and go to https://yourdomain.com/baikal/admin (replace yourdomain.com with your own domain name or IP address). You should see the Baïkal login page.

    Use the following default credentials to log in:

    • Username: admin
    • Password: admin

    Congratulations! You have successfully installed Baïkal on NixOS Latest.

Conclusion

Baïkal is a powerful server that provides CalDAV and CardDAV synchronization for your contacts and calendar. With this tutorial, you have learned how to install Baïkal on NixOS Latest by following a few simple steps. Enjoy using Baïkal!

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!