How to Install Lufi on NixOS Latest

Lufi is a free (as in freedom) and open-source software for sharing files with end-to-end encryption. It is developed by Framasoft, a non-profit association that promotes free software and online services.

In this tutorial, you'll learn how to install Lufi on NixOS Latest, a Linux distribution that emphasizes declarative configuration and reproducibility.

Prerequisites

Before you begin, you should have:

Step 1 — Installing Dependencies

Lufi requires several dependencies to be installed on the system. You can install them by adding the following code to the configuration.nix file:

environment.systemPackages = with pkgs; [
  buildPackages.gcc
  buildPackages.make
  libmaxminddb
  nginx
  perlPackages.CryptX
  perlPackages.DB_File
  perlPackages.DataUniqid
  perlPackages.Image-ExifTool
  perlPackages.JSON
  perlPackages.JSON-WebToken
  perlPackages.LWP-Protocol-https
  perlPackages.MIME-Base64
  perlPackages.MIME-tools
  perlPackages.Net-SSLeay
  perlPackages.Plack
  perlPackages.Plack-Middleware-ReverseProxy
  perlPackages.Proc-Wait3
  perlPackages.Random-XS
  perlPackages.Try-Tiny
  perlPackages.URI
  perlPackages.XML-LibXML
  perlPackages.YAML-LibYAML
  perlPackages.memcached
  perlPackages.starman
  perlPackages.Test-Deep
  perlPackages.Test-Exception
  perlPackages.declare
  perlPackages.dancer2
  perlPackages.dancer2-session-cookie
  perlPackages.dbd-mysql
  perlPackages.memcached
  perlPackages.module-build
  perlPackages.module-build-tiny
  perlPackages.module-find
  perlPackages.module-implementation
  perlPackages.module-manifest
  perlPackages.module-metadata
  perlPackages.module-runtime
  perlPackages.module-versions-report
];

After you edit configuration.nix, perform NixOS rebuild.

sudo nixos-rebuild switch

This command will download all the necessary dependencies for the Lufi installation.

Step 2 — Installing Lufi

To install Lufi, you need to clone the repository from the official Github page.

$ git clone https://framagit.org/fiat-tux/hat-softwares/lufi.git

Then, move to the directory that contains Lufi.

$ cd lufi

To install Lufi, you can run the following command:

$ make install

This command will create the necessary directories and install the Lufi software.

Step 3 — Configuring Lufi

Lufi has a configuration file that you can modify to tailor the settings to your specific needs. The name of the configuration file is config.yml.

$ sudo nano /usr/local/etc/lufi/config.yml

In this file, you can set the following parameters:

email from

This parameter sets the email address that will be used to send the notification messages to the users. Set this to a valid email address.

email_from: "lufi@example.com"

SMTP email settings

Specify the parameters for the SMTP server. Example:

smtp:
    server: "mail.example.com"
    port: 587
    username: "lufi@example.com"
    password: "examplepassword"
    starttls: true
    ignore_cert: false

TLS key and certificate paths

Specify the paths to the TLS key and certificate files.

tls:
    key_file: "/etc/ssl/private/lufi.key"
    cert_file: "/etc/ssl/certs/lufi.crt"
    cert_chain_files: []

Database settings

Specify the details of the MariaDB or MySQL database that Lufi will use.

database:
    driver: "mysql"
    host: "localhost"
    port: 3306
    username: "lufi_user"
    password: ""
    database: "lufi_db"

You can replace the driver, host, port, username, password, and database parameters with your own.

After you have made the necessary changes to the config.yml file, save it and exit.

Then, restart the Lufi service for the changes to take effect.

$ sudo systemctl restart lufi

Step 4 — Accessing Lufi

By default, Lufi runs on port 8080. You can access the web interface by pointing your browser to this URL:

http://localhost:8080/

If you want to use nginx as a reverse proxy, you can replace the default Nginx configuration file with the following:

server {
    listen 80;
    server_name lufi.example.com;

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied any;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";

access_log /var/log/nginx/lufi.access.log;
error_log /var/log/nginx/lufi.error.log;

location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header        X-Real-IP $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header        Host $http_host;
proxy_set_header        X-Nginx-Proxy true;
proxy_set_header        Upgrade $http_upgrade;
proxy_set_header        Connection "upgrade";
proxy_set_header        X-Forwarded-Proto $scheme;
proxy_redirect off;
}

listen [::]:80;
server_name lufi.example.com;

return 301 https://$server_name$request_uri;
}

Don't forget to change server_name to your own domain name.

After editing the Nginx configuration file, reload the Nginx service.

$ sudo systemctl reload nginx

Conclusion

You now have an instance of Lufi installed on your NixOS Latest system. You can upload files securely and share them with your friends or colleagues.

To ensure that your data is safe, you can configure backups and take other security measures to protect your system.

Enjoy using Lufi on NixOS Latest!

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!