How to Install Pretalx on NixOS Latest

pretalx.org/">Pretalx is a conference management system that helps organizers manage events, track submissions, and schedule talks. NixOS is a Linux distribution that provides a functional package management system. In this tutorial, we'll cover how to install Pretalx on NixOS.

Prerequisites

Steps

  1. Update the Nix package manager and the system:
$ sudo nix-channel --update
$ sudo nixos-rebuild switch
  1. Install the required dependencies for running Pretalx:
$ sudo nix-env -i postgresql
$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql
  1. Create a new PostgreSQL database for Pretalx:
$ sudo -u postgres psql
postgres=# CREATE DATABASE pretalx;
postgres=# CREATE USER pretalx WITH PASSWORD 'password';
postgres=# ALTER ROLE pretalx SET client_encoding TO 'utf8';
postgres=# ALTER ROLE pretalx SET default_transaction_isolation TO 'read committed';
postgres=# ALTER ROLE pretalx SET timezone TO 'UTC';
postgres=# GRANT ALL PRIVILEGES ON DATABASE pretalx TO pretalx;
postgres=# \q
  1. Install Pretalx using the Nix package manager and the Pretalx overlay:
$ sudo mkdir -p /etc/nixos/overlays
$ sudo bash -c 'cat > /etc/nixos/overlays/pretalx.nix <<EOF
self: super:
let
  pretalx = import (builtins.fetchTarball https://github.com/greenmang0/pretalx-nix/archive/master.tar.gz);
in
{
  nixpkgs.overlays = [ pretalx.overlay ];
}
EOF'
$ sudo nix-env -i pretalx
  1. Update the Nginx configuration file to serve the Pretalx web interface:
$ sudo bash -c 'cat > /etc/nixos/nginx.conf <<EOF
worker_processes 1;

error_log /var/log/nginx/error.log;

events {
  worker_connections 1024;
}

http {
  sendfile on;

  server {
    listen 80;
    server_name localhost;

    location / {
      proxy_pass http://127.0.0.1:8000;
      proxy_set_header Host \$host;
      proxy_set_header X-Real-IP \$remote_addr;
      proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Host \$server_name;
      proxy_set_header X-Forwarded-Proto \$scheme;
    }

    location /static/ {
      alias /var/lib/pretalx/static/;
    }
  }
}
EOF'
  1. Modify the Pretalx configuration file to use the PostgreSQL database and update the Nginx configuration file to reflect your server name:
$ sudo mkdir -p /etc/pretalx
$ sudo bash -c 'cat > /etc/pretalx/config.yml <<EOF
database:
  url: postgresql://pretalx:password@localhost/pretalx

event:
  name: My Conference
  slug: my-conference

mail:
  backend: smtp
  host: mail.example.com
  port: 587
  tls: true
  user: user@example.com
  password: your-password-here

update:
  check_days: 1

redis:
  url: redis://localhost:6379/0

paths:
  data: /var/lib/pretalx/data
  media: /var/lib/pretalx/media

logging:
  version: 1
  disable_existing_loggers: false
  handlers:
    console:
      class: logging.StreamHandler
      formatter: default
    file:
      class: logging.handlers.RotatingFileHandler
      filename: /var/log/pretalx.log
      maxBytes: 10485760
      backupCount: 20
      formatter: default
  loggers:
    pretalx:
      handlers: [console, file]
      level: INFO
      propagate: false
    django.request:
      handlers: [console, file]
      level: INFO
      propagate: false
    django.views.debug:
      handlers: [console, file]
      level: INFO
      propagate: false
  formatters:
    default:
      format: "%(asctime)s %(levelname)s %(name)s %(message)s"
      datefmt: "%Y-%m-%d %H:%M:%S"

server:
  bind: localhost:8000
  worker_processes: 2
EOF'
  1. Create the necessary directories and files and set the correct permissions:
$ sudo mkdir -p /var/lib/pretalx/static
$ sudo chown -R pretalx: /var/lib/pretalx
$ sudo chmod -R g+rw /var/lib/pretalx
$ sudo touch /var/log/pretalx.log
$ sudo chown pretalx: /var/log/pretalx.log
  1. Start the Pretalx web server and Nginx:
$ sudo -u pretalx pretalx migrate
$ sudo -u pretalx gzip -dc /nix/store/*pretalx*/lib/python*/site-packages/pretalx/data/dist/*template.tar.gz | sudo -u pretalx tar -xC /var/lib/pretalx
$ sudo systemctl start nginx
$ sudo -u pretalx pretalx runserver
  1. Access the Pretalx web interface by visiting http://your-server-name in your web browser.

You're done! Now you can use Pretalx to manage your conference or event.

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!