How to Install Asciinema on NixOS Latest

In this tutorial, we will be learning how to install Asciinema on NixOS Latest. Asciinema is a free and open-source tool used for recording and sharing terminal sessions. The Asciinema server can be installed in your own infrastructure, allowing you to share recorded terminal sessions with your team or the world.

Prerequisites

Before we begin, make sure you have the following installed in your system:

  • NixOS Latest
  • Git

Step 1: Clone the Asciinema Repository

Before we can install the Asciinema server on our system, we need to clone the repository. Run the following command to clone the Asciinema repository:

git clone https://github.com/asciinema/asciinema-server.git

This will create a directory called asciinema-server in your current working directory.

Step 2: Install Nix

Asciinema server is built using Nix, so we need to make sure Nix is installed on our system. If not already installed, run the following command:

sudo nix-env -iA nixpkgs.nix

Step 3: Build Asciinema Server

Now we are ready to build and install the Asciinema server. Navigate to the asciinema-server directory and run the following commands:

nix-shell
chmod +x scripts/build && scripts/build

This command will fetch dependencies, build the application, and install it on your system.

Step 4: Configure Asciinema Server

By default, Asciinema server is configured to use SQLite as its database. However, you can change this by editing the config/config.json file. You can define environment variables to configure the server.

For example, to change the database from SQLite to PostgreSQL, you can set the following environment variables:

export ASCIINEMA_DATABASE_URL=postgres://user:pass@host/dbname
export ASCIINEMA_REDIS_URL=redis://host:port

Step 5: Start Asciinema Service

After configuring the server, start the Asciinema service by running the following command:

systemctl --user start asciinema

This will start the Asciinema server as a user service. The server logs can be accessed at ~/.local/var/log/asciinema/asciinema.log

Conclusion

Asciinema is now installed and running on your NixOS Latest system. You can now start recording terminal sessions and sharing them with your team or the world.