diff --git a/lib/modules/users.nix b/lib/modules/users.nix index 495bb576..5a8db371 100644 --- a/lib/modules/users.nix +++ b/lib/modules/users.nix @@ -5,6 +5,17 @@ types ; + syncType = types.submodule ( + { ... }: { + options = { + cacheDuration = mkOption { + type = types.nullOr types.str; + description = "The amount of time to keep cached files."; + default = null; + }; + }; + }); + userType = types.submodule ( { ... }: { options = { @@ -33,6 +44,14 @@ }; git = (import ./git/options.nix) { inherit lib; }; + + rclone = { + configurations = mkOption { + type = types.attrsOf syncType; + description = "The configurations of the rclone mounts."; + default = {}; + }; + }; }; }); in { diff --git a/profiles/Generic/config.nix b/profiles/Generic/config.nix index aa3bb897..b9431462 100644 --- a/profiles/Generic/config.nix +++ b/profiles/Generic/config.nix @@ -46,6 +46,13 @@ ]; defaultShell = "fish"; + + rclone = { + configurations = { + nextcloud = {}; + proton = {}; + }; + }; }; }; diff --git a/scripts/Common/Software/rclone/main.fish b/scripts/Common/Software/rclone/main.fish index 9110684e..13333069 100644 --- a/scripts/Common/Software/rclone/main.fish +++ b/scripts/Common/Software/rclone/main.fish @@ -7,5 +7,40 @@ begin sudo cp "$dir/rclone.service" "$dir/rclone.target" "$dir/rclone@.service" /etc/systemd/user end + function userConfig -V dir -a name + source "$dir/../../Scripts/config.fish" + set -l key "valhalla.users.$name.rclone.configurations" + set -l configs (getConfig "$key" --apply "builtins.attrNames") + + if [ (echo "$configs" | jq "length") -gt 0 ] + if [ "$XDG_SESSION_TYPE" = "tty" ] + set -l entryPoint ~"$name"/.config/autostart/PortValhallaProfile.desktop + sudo -u "$name" mkrit -p "$(dirname "$entryPoint")" + + begin + printf %s\n \ + "#!/user/bin/env xdg-open" \ + "[Desktop Entry]" \ + "Name=PortValhalla Profile" \ + "Type=Application" \ + "Terminal=false" ( + printf "%s " \ + "Exec=env" \ + "CONFIG_MODULE=$(echo "$CONFIG_MODULE" | string escape)" \ + "konsole -e fish $(realpath (status filename) | string escape) userConfig" + ) + end | sudo -u "$name" tee "$entryPoint" > /dev/null + + sudo chmod +x "$entryPoint" + sudo -u "$name" dbus-launch --exit-with-session startplasma-wayland &> /dev/null + rm "$entryPoint" + rm ~"$name"/.config/plasma-welcomerc + else + echo "Please complete the setup of your rclone configurations!" + rclone config || true + end + end + end + runInstaller $argv end