How to Install Coral on NixOS Latest

Corals is an open source project of The Coral Project that aims to make it easier for newsrooms and journalism organizations to talk with their audiences.

This tutorial will guide you through the process of installing Coral on the latest version of NixOS.

Prerequisites

Before you start, make sure you have the following:

Step 1: Add Coral to nixpkgs

To install Coral on NixOS, you need to add it to the nixpkgs repository. Follow the steps below to add Coral.

  1. Open the terminal and switch to the root user by running su command.

  2. Navigate to the nixpkgs directory by running cd /etc/nixos.

  3. Edit the configuration.nix file by running nano configuration.nix.

  4. Add the Coral package to the environment.systemPackages list by adding the following lines:

    environment.systemPackages = [
      (import (fetchTarball "https://github.com/coralproject/coral.nix/archive/master.tar.gz") {})
    ];
    

    This instruction will fetch the latest Coral package from its source repository and add it to the NixOS package manager.

  5. Save and close the file.

  6. Run nixos-rebuild switch to rebuild the NixOS configuration.

Step 2: Set up Coral configuration files

After adding Coral to nixpkgs, you now need to set up the configuration files to enable it on your website. Follow these steps to set up the configuration files:

  1. Navigate to the coral-files directory by running cd /etc/nixos/coral-files.

  2. In this directory, you will see the two necessary files you need to edit: envrc and dotenv.

  3. Edit the envrc file by running nano envrc.

  4. Add your domain name to the CORAL_TALK_URL variable like this:

    export CORAL_TALK_URL="https://your-domain.com"
    
  5. Save and close the file.

  6. Next, edit the dotenv file by running nano dotenv. You need to fill in the following variables:

    # API keys and secrets
    export AWS_ACCESS_KEY_ID="your-aws-access-key-id"
    export AWS_SECRET_ACCESS_KEY="your-aws-secret-access-key"
    export AWS_REGION="your-aws-region"
    
    export TALK_DEVELOPMENT=false
    export TALK_SESSION_SECRET="some-random-secret-value-that-you-should-generate"
    
    # configuration
    export TALK_DATABASE_URI="mongodb://localhost:27017/coral-database"
    
    # CORS
    export TALK_CORS_WHITELIST="*"
    export TALK_CLIENT_ORIGIN="https://your-domain.com"
    
    # CDN
    export TALK_CDN_URL=""
    
    # moderation
    export TALK_MODERATION_ENDPOINT="https://your-moderation-endpoint.com"
    export TALK_MODERATION_USERNAME="your-moderation-username"
    export TALK_MODERATION_PASSWORD="your-moderation-password"
    

    Note that the values above are just placeholders. You should replace them with your own.

  7. Save and close the dotenv file.

Step 3: Start and enable Coral

Follow these steps to start and enable Coral.

  1. Run sudo systemctl enable coral to enable the Coral service.
  2. Run sudo systemctl start coral to start the Coral service.
  3. Check that Coral is running by going to https://your-domain.com/admin in your browser.

Congratulations! You have successfully installed Coral on NixOS. You can now use it to power discussions on your website.

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!