Quick & easy cloud storage with dufs and NixOS
dufs1 (the distinctive file utility server) is a cloud storage replacement for those looking to move away from third-party services like Google Drive or Proton Drive. it supports WebDAV and HTTPS file transfer protocols.
It's very easy to set up and get going in NixOS using a Docker container.
Set up dufs
First, enable docker in your configuration.nix
:
virtualisation.docker.enable = true;
Then define a Docker container, either in your
configuration.nix
or in a custom module:
virtualisation.oci-containers = {
backend = "docker";
containers.dufs = {
# automatically restart server after reboot
autoStart = true;
image = "sigoden/dufs";
ports = [
"5000:5000"
];
# the files i want to serve are in /srv/dufs
volumes = [
"/srv/dufs:/data"
];
# tells dufs to serve the files in the docker volume /data
cmd = [
"-A"
"/data"
];
};
};
Rebuild your configuration by running
sudo nixos-rebuild switch
and head on over to
http://localhost:5000
to behold your lovely files. Now we
need a method to access our files on other devices inside (and outside) of
our home network. Tailscale2
provides commands to accomplish this easily.
Set up Tailscale
You can use Tailscale to access the files on other devices inside (and outside) of your home network. Tailscale is like a crazy-fast vpn with a bunch of other comfort features like MagicDNS3, keyless SSH4 and easy HTTPS5.
To enable it in nixos, add the following to your
configuration.nix
:
services.tailscale.enable = true;
networking.firewall.trustedInterfaces = [ "tailscale0" ];
Once again, rebuild your configuration by running
sudo nixos-rebuild switch
and run
tailscale up
to start tailscale. The tailscale connection
will persist on reboot, so no need to worry resume adding it to your
init process.
I recommend enabling MagicDNS in the admin console > DNS > MagicDNS, but
if you prefer not to, your server's IP address will be visible by
running tailscale ip -4
.
Head over to http://<hostname or ip>:5000
on one of
your other machines running tailscale to upload, download, and view your
self-hosted files.
dufs clients
As for client recommendations, Round Sync6 on android is quite good. it supports both WebDAV and HTTPS remotes, I chose to use WebDAV when connecting.
Thanks for stopping by ^.^