How to Install Minio on Latest nixOS
In this tutorial, we will learn how to install Minio on nixOS latest version. Minio is an open-source, S3-compatible object storage server that can be used to store large amounts of data.
Step 1: Install Nix
First, we need to install Nix, which is a package manager for nixOS.
curl https://nixos.org/nix/install | sh
Once the installation is complete, run the following command to ensure that Nix is correctly installed.
nix-shell --run "echo 'Nix is installed!'"
Step 2: Install Minio
Now, we can proceed to install Minio. We will first create a new file minio.nix in the current working directory
nano minio.nix
and paste the following into the file:
{ pkgs }:
let
minioConfig = {
anonymous_access = true;
http_addr = "0.0.0.0:9000";
};
in
with pkgs;
stdenv.mkDerivation {
name = "minio";
version = "2022-01-04T03-57-41Z";
src = fetchurl {
url = "https://dl.minio.io/server/minio/release/linux-amd64/minio";
sha256 = "0c8d1fea84bbec47d1bacc41e458c7e7999500dabf6c399bd6a2d8a2463d545e";
};
installPhase = ''
mkdir -p $out/bin
cp minio $out/bin/minio
'';
meta = {
description = "Open-source, S3-compatible object storage server";
homepage = https://minio.io;
license = licenses.apache2;
};
config = {
# Minio configuration
environment.MINIO_ACCESS_KEY = "minioadmin";
environment.MINIO_SECRET_KEY = "minioadmin";
environment.MINIO_OPTS = "--config-dir $out/etc/minio --address :9000";
users.extraUsers.minio = {
name = "minio";
uid = 4711;
group = "users";
home = "/var/lib/minio";
};
systemd.services.minio = {
description = "Minio object storage server";
after = [ "network.target" ];
environment = {
MINIO_OPTS = "--config-dir ${configFile}/minio_config/ --address ${minioConfig.http_addr}";
};
serviceConfig = {
User = "minio";
ExecStart = "${pkgs.coreutils}/bin/env \\n \\
MINIO_ACCESS_KEY=${environment.MINIO_ACCESS_KEY} MINIO_SECRET_KEY=${environment.MINIO_SECRET_KEY} \\
${pkgs.stdenv.shell} \\
-c 'while true; do \\
${out}/bin/minio server --config-dir ${configFile}/minio_config/ --address ${minioConfig.http_addr}; done'";
ExecStop = "${pkgs.coreutils}/bin/env MINIO_ACCESS_KEY=${environment.MINIO_ACCESS_KEY} MINIO_SECRET_KEY=${environment.MINIO_SECRET_KEY} ${pkgs.stdenv.shell} -c 'kill %1'";
Restart = "always";
RestartSec = "60";
LimitNOFILE = 65536;
LimitNPROC = 4096;
TasksMax = "infinity";
FileDescriptorStoreMax=0;
};
};
};
}
Then, we can run the following command to install Minio:
nix-env -if minio.nix
This will start the installation process and may take a few minutes to complete.
Step 3: Start Minio
After the installation process is complete, we can start the Minio object storage server by running the following command:
sudo systemctl start minio
Once Minio is up and running, you can access it by browsing to the server's IP address or hostname with port 9000 in a web browser.
Conclusion
In this tutorial, we have learned how to install Minio on nixOS latest version. We have also seen how to configure and start the Minio object storage server. You can now start using Minio to store your data and enjoy its scalability and fault-tolerance features.