How to Install Retrospring on NixOS

Retrospring is an open-source federated social network. This tutorial will guide you through the steps to install Retrospring on NixOS.

Requirements:

Step 1: Install Git

Open the terminal and install Git:

sudo nix-env -i git

Step 2: Clone Retrospring

Next, clone the Retrospring repository from GitHub using Git. Enter the following command in the terminal:

git clone https://github.com/retrospring/retrospring.git

Step 3: Generate Certificates

Retrospring uses HTTPS, and you need to generate a self-signed SSL certificate. Install OpenSSL using Nix:

sudo nix-env -i openssl

Generate certificates using OpenSSL:

sudo openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout localhost.key -out localhost.crt -subj '/CN=localhost' -days 365

Enter the required information, such as your country, state, and city of residence.

Step 4: Install PostgreSQL

Install PostgreSQL using Nix:

sudo nix-env -i postgresql

Step 5: Set up a Database

Create a new PostgreSQL database:

sudo -iu postgres createdb retrospring

Set a password for the postgres user account:

sudo -iu postgres psql -c "ALTER USER postgres PASSWORD 'your_password';"

Replace your_password with your desired password.

Step 6: Install Additional Dependencies

Install the additional dependencies required by Retrospring using Nix:

sudo nix-env -i erlang elixir mix nodejs vim

Step 7: Edit Configuration Files

Copy the default configuration files and edit them:

cd retrospring
cp config/config.exs.example config/config.exs
cp config/prod.secret.exs.example config/prod.secret.exs
vim config/config.exs

Edit config/config.exs by replacing the following values:

config :retrospring_web, RetrospringWeb.Endpoint,
  http: [port: 4000, protocol_options: [max_keepalive: 1_000_000, tcp_nodelay: true]],
  url: [host: "localhost", port: 4000],
  cache_static_manifest: "priv/static/cache_manifest.json"

with

config :retrospring_web, RetrospringWeb.Endpoint,
  http: [port: 4000, protocol_options: [max_keepalive: 1_000_000, tcp_nodelay: true]],
  url: [host: "your_server_ip_address", port: 4000],
  cache_static_manifest: "priv/static/cache_manifest.json",
  server: true,
  secure_cookies: :always,
  force_ssl: [rewrite_on: [:x_forwarded_proto], hsts: true]

config :phoenix, :serve_endpoints, true
config :phoenix, :services, true

Replace your_server_ip_address with your server's IP address.

Next, edit config/prod.secret.exs and set the database username, password, and host.

config :retrospring, Retrospring.Repo,
  username: "postgres",
  password: "your_password",
  database: "retrospring",
  hostname: "localhost",
  pool_size: 10

Here, replace your_password with the password you set earlier for the postgres user.

Step 8: Build and Run Retrospring

Build and compile the application:

mix deps.get --only prod
MIX_ENV=prod mix compile
npm install --prefix ./assets
npm run deploy --prefix ./assets

Create the database:

MIX_ENV=prod mix ecto.create
MIX_ENV=prod mix ecto.migrate

Start Retrospring:

PORT=4000 MIX_ENV=prod elixir --erl "-ssl\_dist\_opt verify\_none" -S mix phx.server

Conclusion

Retrospring is now up and running on NixOS Latest. You can access it by visiting https://your_server_ip_address:4000 in your web browser.

Note that this installation is only suitable for development purposes. If you plan to use Retrospring in production, you should secure your SSL certificates with a trusted certificate authority, among other security best practices.

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!