From 13e5a8ad626162357af28ef2d8ade9c739c1e99c Mon Sep 17 00:00:00 2001 From: quinm0 Date: Sat, 14 Mar 2026 19:12:49 -0400 Subject: [PATCH] Squash merge rclone into main --- flake.nix | 1 + nix/mega.nix | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 nix/mega.nix diff --git a/flake.nix b/flake.nix index 4eaa74c..0ee4126 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ ./nix/common.nix ./nix/user-quin.nix ./nix/gui1.nix + ./nix/mega.nix ]; }; }; diff --git a/nix/mega.nix b/nix/mega.nix new file mode 100644 index 0000000..cfefe3c --- /dev/null +++ b/nix/mega.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, modulesPath, ... }: + +let + mountName = "mega"; + mountPath = "/mnt/${mountName}"; + waitForFile = "/mnt/${mountName}/mega_connected"; + rcloneBucket = "data:enc"; + rcloneConfigPath = "/etc/rclone.conf"; +in +{ + + # Service that is good to wait on for the mount to be successful + systemd.services."${mountName}-mount-wait" = { + description = "Rclone mount wait service, good if you want other services to wait for it"; + + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + path = [ pkgs.bash ]; + + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.bash}/bin/bash -c 'while [ ! -e ${waitForFile} ]; do sleep 1; done'"; + RemainAfterExit = true; + }; + }; + + + # Actual mount service + systemd.services."${mountName}-mount" = { + description = "Rclone mount '${mountName}'"; + + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + path = [ pkgs.bash ]; + + serviceConfig = { + ExecStart = "${pkgs.rclone}/bin/rclone mount ${rcloneBucket} ${mountPath} -vv --vfs-cache-mode full --allow-other --fuse-flag allow_other --dir-perms 0777 --file-perms 0777 --umask 0 --default-permissions --dir-cache-time 300h --config ${rcloneConfigPath}"; + }; + }; + + # If docker is installed we'll make it wait to start + systemd.services.docker.after = ["${mountName}-mount-wait.service"]; +} \ No newline at end of file