How to Install EdPaste on NixOS Latest

EdPaste is a self-hosted pastebin tool designed for developers. NixOS is a Linux distribution that provides a simple and efficient way to manage packages and configuration files. In this tutorial, we will guide you on how to install EdPaste on NixOS Latest.

Prerequisites

Before we begin, make sure to have the following prerequisites:

Step 1 - Clone the Repository

To get started, log in to your NixOS server and clone the EdPaste repository by running the following command:

$ git clone https://github.com/ptnr/EdPaste.git

Step 2 - Install Dependencies

EdPaste requires some dependencies to work properly. You should install them by running the following command:

$ sudo nix-shell --packages 'ghc.withPackages (pkgs: with pkgs; [ postgresql_10 postgresql_10.contrib cabal-install ])'

Step 3 - Configure PostgreSQL

EdPaste uses PostgreSQL as a database backend. You need to create a new PostgreSQL database and user for EdPaste. Start by logging in to the PostgreSQL server:

$ sudo -u postgres psql

Then, create a new database:

postgres=# create database edpaste;

And a new user:

postgres=# create user edpaste with encrypted password 'password';

Assign the user to the database:

postgres=# grant all privileges on database edpaste to edpaste;

Exit PostgreSQL:

postgres=# \q

Step 4 - Configure EdPaste

To configure EdPaste, navigate to the cloned repository:

$ cd EdPaste

Edit the config/settings.yml file and fill in the appropriate values:

database_url: postgresql://edpaste:password@localhost/edpaste
secret_key: "<INSERT_RANDOM_SECRET_KEY>"
hostname: "<YOUR_DOMAIN>"

You should generate a random secret key for your instance, for example, by running:

$ openssl rand -base64 32

Step 5 - Build and Run EdPaste

To build and run EdPaste, run the following commands:

$ cabal new-build --enable-tests --enable-benchmarks --ghc-option=-O2
$ ./scripts/migrate-db.sh
$ ./scripts/run-server.sh

The migrate-db.sh script creates the necessary tables in the PostgreSQL database. After running this, you can start the web server by running the run-server.sh script.

Step 6 - Configure Nginx

To configure Nginx to serve EdPaste, create a new Nginx server block:

$ sudo vim /etc/nginx/sites-available/edpaste

And add the following configuration:

server {
  listen 80;
  server_name <YOUR_DOMAIN>;
  location / {
    proxy_pass http://localhost:8080;
  }
}

Then, enable the server block by creating a symlink:

$ sudo ln -s /etc/nginx/sites-available/edpaste /etc/nginx/sites-enabled/

And restart Nginx:

$ sudo systemctl restart nginx

Step 7 - Access EdPaste

You can now access EdPaste by navigating to your domain in a web browser. Make sure to use http or https depending on your Nginx configuration.

Congratulations, EdPaste is now up and running on your NixOS Latest server! You can use it to share code snippets with your colleagues or the wider developer community.

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!