From 8f808b5c8c4d046a7c860421ba07084637a6cb4b Mon Sep 17 00:00:00 2001 From: spy4x <2spy4x@gmail.com> Date: Tue, 12 Mar 2024 00:59:45 +0800 Subject: [PATCH] feat(nix): add Rclone for Google Drive folder sync --- configuration.nix | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 8e9c705..ae923c5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -6,6 +6,8 @@ let sshConfigPath = ./ssh-config.nix; + gdrivePath = "/home/spy4x/gdrive"; + curBin = "/run/current-system/sw/bin"; in { imports = @@ -25,7 +27,15 @@ in firewall = { enable = true; allowedTCPPorts = [ - 80 # Web server to debug apps from mobile + # BEGIN Web server to debug apps from mobile + 80 + 4200 + 4201 + 5173 + 5174 + 8080 + 8081 + # END Web server to debug apps from mobile 53317 # LocalSend ]; }; @@ -118,6 +128,7 @@ in obs-studio # Video recorder and stream software solaar # Logitech devices GUI. Strictly use with sudo, otherwise it doesn't see devices. localsend # Share files/text/data with other devices in local network without internet. OSS alternative to AirDrop. + rclone # Sync Google Drive with a local folder ]; }; programs.steam.enable = true; # Install Steam for games management @@ -134,6 +145,27 @@ in services.xserver.displayManager.autoLogin.enable = true; services.xserver.displayManager.autoLogin.user = "spy4x"; + # RClone Google Drive service + systemd.services.rclone-gdrive-mount = { + # Ensure the service starts after the network is up + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" ]; + requires = [ "network-online.target" ]; + + # Service configuration + serviceConfig = { + Type = "simple"; + ExecStartPre = "${curBin}/mkdir -p ${gdrivePath}"; + ExecStart = "${pkgs.rclone}/bin/rclone mount gdrive: ${gdrivePath}"; + ExecStop = "${curBin}/fusermount -u ${gdrivePath}"; + Restart = "on-failure"; + RestartSec = "10s"; + User = "spy4x"; + Group = "users"; + Environment = [ "PATH=/run/wrappers/bin/:$PATH" ]; # Required environments + }; + }; + # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 systemd.services."getty@tty1".enable = false; systemd.services."autovt@tty1".enable = false;