How to Install FileGator on NixOS Latest

FileGator is a file manager that runs in the browser. It allows users to manage and share files with others. In this tutorial, we will be installing FileGator on NixOS Latest.

Prerequisites

Before we get started with the installation, please ensure that you have the following prerequisites:

You also need to be comfortable with using the command line.

Step 1: Create a NixOS Service

In NixOS, we use systemd services to manage our applications. To create a new service, create a new file in the /etc/nixos directory, let's call it filegator.nix.

sudo nano /etc/nixos/filegator.nix

Now paste the code below to the file:

{
  systemd.services.filegator = {
    description = "FileGator Web Based File Manager";
    wantedBy = [ "multi-user.target" ];

    environmentVariables = {
      DATABASE_URL = "sqlite:///var/lib/filegator/filegator.db";
      PORT = "8080";
      DEBUG = "true";
    };

    serviceConfig = {
      Type = "simple";
      ExecStart = "${pkgs.nodejs}/bin/node ${path}/app.js";
      Restart = "always";
      RestartSec = "10";
    };
  };
}

There are some environment variables that we need to set, so that the service runs correctly. The database url and port could be different according to your preference.

Step 2: Download and Configure FileGator

Next, we need to download and configure FileGator. We will do this by creating a new directory and then downloading FileGator using Git.

sudo mkdir /var/lib/filegator
sudo chown youruser:youruser /var/lib/filegator
git clone https://github.com/filegator/filegator.git /var/lib/filegator

Next, we need to install the dependencies with the following command.

cd /var/lib/filegator && npm install

Step 3: Configure NixOS

To configure NixOS we need to edit the configuration.nix file:

sudo nano /etc/nixos/configuration.nix

We need to add the following line to our system configuration:

services.systemd.services.filegator = { enable = true; };

This will enable the service that we created in Step 1.

Step 4: Start FileGator

We're now ready to start the service with the following command:

sudo systemctl start filegator

The service should now be running. To check the status of the service, run the following command:

sudo systemctl status filegator

If everything worked correctly, you should see output similar to the following:

● filegator.service - FileGator Web Based File Manager
   Loaded: loaded (/etc/systemd/system/filegator.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-09-06 18:49:34 UTC; 2min 0s ago
 Main PID: 991 (node)
    Tasks: 11 (limit: 4915)
   Memory: 25.2M
   CGroup: /system.slice/filegator.service
           └─991 /nix/store/8x5q3c5fnw3mijm48l1ajmz89xpbh15g-nodejs-12.16.2/bin/node /var/lib/filegator/app.js

Sep 06 18:49:34 example.com node[991]: App running on port 8080

Step 5: Access FileGator

To access FileGator, open a web browser and enter the IP address or domain name of your server. You should now be able to see the FileGator login page and you can start managing your files using the web interface.

Conclusion

That's it! In this tutorial, we've shown you how to install FileGator on NixOS Latest. You can now manage and share files with others using FileGator.

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!