Installing Traduora on NixOS

Introduction

Traduora is an open-source translation management tool that facilitates the translation of software applications. In this tutorial, we will guide you through the steps of installing Traduora on the latest version of NixOS.

Prerequisites

Before starting this tutorial, ensure the following prerequisites are met:

Steps

1. Update the system

Ensure your system is updated to the latest version by running:

sudo nixos-rebuild switch

2. Install required packages

Traduora requires some packages that are not installed by default in NixOS, including PostgreSQL, Redis, and Python. Install these packages by running:

sudo nix-env -i postgresql redis python

3. Create the database

Traduora requires a PostgreSQL database to run. Create a database by logging in to the PostgreSQL server with the following command:

sudo -u postgres psql

Then, create a user and database using the following commands:

CREATE USER traduora WITH PASSWORD 'traduora';
CREATE DATABASE traduora OWNER traduora;

4. Install Traduora

Traduora can be installed through NixOS's user package management system. Create a new file called traduora.nix in /etc/nixos/ and add the following lines:

{ pkgs, ... }:

let
  pythonPackages = pkgs.python3Packages;
  django = pythonPackages.django_22;
  psycopg2 = pythonPackages.psycopg2;
  whitenoise = pythonPackages.whiteNoise;
  uWSGI = pythonPackages.uWSGI;
  redis = pkgs.redis;
  supervisor = pkgs.supervisor;
  nodejs = pkgs.nodejs-12_x;
  yarn2nix = pkgs.yarn2nix;
  virtualenvWrapper = pythonPackages.virtualenvWrapper;
  pythonMagic = pythonPackages.python-magic;
in pythonPackages.mkVirtualEnv {
  name = "traduora";
  packages = [
    django
    psycopg2
    whitenoise
    uWSGI
    redis
    supervisor
    nodejs
    yarn2nix
    virtualenvWrapper
    pythonMagic
  ];
  pythonPath = "${pythonPackages.python3}/bin/python3";
}

This file specifies the required Python packages, as well as other dependencies.

Then, add the following lines to your /etc/nixos/configuration.nix file:

{
  environment.systemPackages = [pkgs.yarn];

  # Your other configurations...

  imports = [
    /etc/nixos/traduora.nix
  ];

  # Your other configurations...
}

After making the changes, update your system with the command:

sudo nixos-rebuild switch

5. Configure Traduora

Traduora needs to be configured with a local.py file. Copy the configuration file by running the following command:

sudo cp /home/traduora/traduora/local.py.example /home/traduora/traduora/local.py

Replace the database settings in local.py with the following:

DATABASES = {
    'default': {
        'ENGINE':   'django.db.backends.postgresql',
        'NAME':     'traduora',
        'USER':     'traduora',
        'PASSWORD': 'traduora',
        'HOST':     'localhost',
        'PORT':     '5432',
    },
}

6. Run Traduora

Traduora can now be run using the following command:

sudo -u traduora -H /var/lib/traduora/bin/python3 /var/lib/traduora/traduora/manage.py runserver

You can access Traduora by opening your web browser and navigating to http://localhost:8000.

Conclusion

In this tutorial, we have installed Traduora on the latest version of NixOS. You should now be able to use Traduora for your translation management needs.

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!