How to Install Kafka on nixOS Latest

Kafka is an open-source distributed streaming platform which is used to build real-time streaming data pipelines and streaming applications. In this tutorial, we will learn how to install Kafka on nixOS latest.

Prerequisites

Before you start the installation process, make sure that you have the following prerequisites installed on your system:

  • nixOS latest version
  • Java JDK 8 or above

Step 1: Download Kafka

First, we need to download Kafka from the official website. To download the latest version of Kafka, use the following command on your terminal:

$ wget http://mirror.cogentco.com/pub/apache/kafka/3.0.0/kafka_3.0.0.tgz

This will download the Kafka binary tarball to your system.

Step 2: Extract Kafka

Once the download is complete, we need to extract the Kafka tarball. Run the following command to extract the Kafka tarball:

$ tar -xvf kafka_3.0.0.tgz

This will create a new directory called kafka_3.0.0.

Step 3: Set Environment Variables

Before we can run Kafka, we need to set some environment variables. Add the following lines to your shell configuration file (e.g. .bashrc or .zshrc):

export KAFKA_HOME=/path/to/kafka_3.0.0
export PATH=$PATH:$KAFKA_HOME/bin

Replace /path/to/kafka_3.0.0 with the actual path to the Kafka directory.

Once you have added these lines, run the following command to reload your shell configuration:

$ source ~/.bashrc

Step 4: Start Kafka

Now that we have set the environment variables, we can start Kafka. Run the following command to start the Kafka server:

$ kafka-server-start.sh $KAFKA_HOME/config/server.properties

This will start the Kafka server in the foreground.

Conclusion

In this tutorial, we learned how to install Kafka on nixOS latest. Now you can start building real-time streaming data pipelines and streaming applications using Kafka.