From ee2b51bbc13626161d89612d638c38d0d115efeb Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 4 Aug 2024 03:48:07 +0200 Subject: [PATCH] Modularize nextcloud and remove need for GUI application --- hardware/spaceship/configuration.nix | 19 ++++++++++ modules/programs/hyprland/hyprland.nix | 5 +-- modules/programs/nextcloud.nix | 42 ---------------------- programs/default.nix | 1 + programs/sync.nix | 48 ++++++++++++++++++++++++++ secrets/secrets.yaml | 6 ++-- 6 files changed, 74 insertions(+), 47 deletions(-) create mode 100644 programs/sync.nix diff --git a/hardware/spaceship/configuration.nix b/hardware/spaceship/configuration.nix index 1aff9cd..e236f69 100644 --- a/hardware/spaceship/configuration.nix +++ b/hardware/spaceship/configuration.nix @@ -89,5 +89,24 @@ in greetd = { resolution = "3440x1440@180"; }; + nextcloud = { + synclist = [ + { + name = "document_sync"; + remote = "Documents"; + local = "/home/${config.conf.username}/Documents"; + } + { + name = "picture_sync"; + remote = "Pictures"; + local = "/home/${config.conf.username}/Pictures"; + } + { + name = "phone_sync"; + remote = "Phone/Stuff"; + local = "/home/${config.conf.username}/Videos/Phone/Stuff"; + } + ]; + }; }; } diff --git a/modules/programs/hyprland/hyprland.nix b/modules/programs/hyprland/hyprland.nix index a9edb5e..6a8c0c1 100644 --- a/modules/programs/hyprland/hyprland.nix +++ b/modules/programs/hyprland/hyprland.nix @@ -1,6 +1,6 @@ { config, lib, options, pkgs, ... }: { imports = [ - + ]; options.mods = { @@ -305,7 +305,8 @@ "ironbar" "firefox" "oxipaste_daemon" - "nextcloud --background" + # should be taken care of with the new systemd services + # "nextcloud --background" "oxinoti" ] ++ config.mods.hyprland.extra_autostart; diff --git a/modules/programs/nextcloud.nix b/modules/programs/nextcloud.nix index d6a0b10..7f91dce 100644 --- a/modules/programs/nextcloud.nix +++ b/modules/programs/nextcloud.nix @@ -36,46 +36,4 @@ }; }; - # config = - # let - # username = config.mods.nextcloud.username; - # password = config.sops.secrets.nextcloud; - # url = config.mods.nextcloud.url; - # synclist = config.mods.nextcloud.synclist; - # name = "test"; - # local = "test"; - # remote = "test"; - # in - # lib.mkIf config.mods.nextcloud.enable - # (lib.optionalAttrs (options?systemd.user.startServices) #{ - # builtins.listToAttrs - # (map - # ({ name, remote, local }: { - # systemd.user = { - # services."${name}" = { - # Unit = { - # Description = "Auto sync Nextcloud"; - # After = "network-online.target"; - # }; - # Service = { - # Type = "simple"; - # ExecStart = "${pkgs.nextcloud-client}/bin/nextcloudcmd -h --path ${remote} ${local} https://${username}:${password}@${url}"; - # TimeoutStopSec = "180"; - # KillMode = "process"; - # KillSignal = "SIGINT"; - # }; - # Install.WantedBy = [ "multi-user.target" ]; - # }; - # timers.${name} = { - # Unit.Description = "Automatic sync files with Nextcloud when booted up after 1 minute then rerun every 60 minutes"; - # Timer.OnBootSec = "1min"; - # Timer.OnUnitActiveSec = "60min"; - # Install.WantedBy = [ "multi-user.target" "timers.target" ]; - # }; - # startServices = true; - # }; - # # }); - # })) - # synclist - # ); } diff --git a/programs/default.nix b/programs/default.nix index 406287c..355d768 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -37,6 +37,7 @@ in ./oxi/default.nix ./themes/default.nix ./individual_configs/default.nix + ./sync.nix ] ++ base_imports ++ lib.optional (builtins.pathExists mod) mod; }; diff --git a/programs/sync.nix b/programs/sync.nix new file mode 100644 index 0000000..281e4eb --- /dev/null +++ b/programs/sync.nix @@ -0,0 +1,48 @@ +{ config, pkgs, options, lib, ... }: +let + username = config.mods.nextcloud.username; + password = config.sops.secrets.nextcloud.path; + url = config.mods.nextcloud.url; + synclist = config.mods.nextcloud.synclist; +in +lib.mkIf config.mods.nextcloud.enable { + systemd.user = { + services = + (builtins.listToAttrs + (map + (opts: { + name = "${opts.name}"; + value = { + Unit = { + Description = "Auto sync Nextcloud"; + After = "network-online.target"; + }; + Service = { + Type = "simple"; + ExecStart = "${pkgs.nextcloud-client}/bin/nextcloudcmd -h --path ${opts.remote} ${opts.local} https://${username}:$(bat ${password})@${url}"; + TimeoutStopSec = "180"; + KillMode = "process"; + KillSignal = "SIGINT"; + }; + Install.WantedBy = [ "multi-user.target" ]; + }; + }) + synclist + )); + timers = + (builtins.listToAttrs + (map + (opts: { + name = "${opts.name}"; + value = { + Unit.Description = "Automatic sync files with Nextcloud when booted up after 1 minute then rerun every 60 minutes"; + Timer.OnBootSec = "1min"; + Timer.OnUnitActiveSec = "60min"; + Install.WantedBy = [ "multi-user.target" "timers.target" ]; + }; + }) + synclist + )); + startServices = true; + }; +} diff --git a/secrets/secrets.yaml b/secrets/secrets.yaml index b0d8ae7..9c2f429 100644 --- a/secrets/secrets.yaml +++ b/secrets/secrets.yaml @@ -5,15 +5,15 @@ hub_pub: ENC[AES256_GCM,data:6vIAQWFMIR+HnERg+A4jKu/MW+e7eLQplmdJyBeuBL9tvxH1idT lab_pub: ENC[AES256_GCM,data:rlHCiqGnoaPiQBaZQRT+bEjfNF7jNO4CGPoCOKJ1o7nv7i2jPy6Bq9OMBHXsMHI9oGfEhyKCDHdpJ65aI07KJC/fMoMoAyiNmalwNOn26jbgj84mfENS3IYbfKxQVXAUCJHE5m1cFsm7,iv:8SLdHLYq2tlfHBjdeDoByEzGuu3TURj4+KJvQfPuaWA=,tag:mmGXlRwQ0UoVIAJE6d1OUQ==,type:str] dashie_pub: ENC[AES256_GCM,data:k6JIJOKDJcGSW47Z8y0EYxNl/vaPRVbIn35CSA57snEzYnk5GpU+1NfPDniWoAGRkpIwicgN6kpzssRlKOmVudvwMejSLv4VkLRBjrsApVFECwoIBLUNGUSDaMcIwC/BYu4jfjGaozBj,iv:0EZ0rptLdmcuTU1BGOILaaDTrc7aZGJCCxgjUESqi0M=,tag:dlQs/ugBGxnSrNj/bRSJSw==,type:str] server_pub: ENC[AES256_GCM,data:87nTYzA8CykOPjfZS2As8+JB/ysJvHXFYbPIBA8Nus8Y3nI3Tl2F/f7mUVFBT+4mmOFTTwxghEnkpgTg/vzUm6W4wb19rIcv11eM7HYaGl5oI44a44rBJn2+PKlfIgXVgaY=,iv:O7I7kkZ44McXzCt3wH1cM3MJCShxu2O+0U0+Y6rwePo=,tag:q5D5AGMmFyiNhQNR8dRB+g==,type:str] -nextcloud: ENC[AES256_GCM,data:gJOgw6lYjEDt3Xgqm4Y2P8uqyCpP8hYXkbU=,iv:9J6ksbxnmWBqOMGcRzcV7/4pnEfeltn9JuSFownXZSk=,tag:trnz5520V01aPsef9sxJuw==,type:str] +nextcloud: ENC[AES256_GCM,data:hjpS1WKsQJ6U2XX3GAbVP93VBAE8hKUdBRD9nI5Yiw==,iv:QaJNScNaxLLArzHLutIWdgN4m+9F0+Ym0FOcL53ygeQ=,tag:PamHgZJ+rsb3Dno2kEZRpQ==,type:str] sops: kms: [] gcp_kms: [] azure_kv: [] hc_vault: [] age: [] - lastmodified: "2024-08-03T20:23:57Z" - mac: ENC[AES256_GCM,data:e3fQXTDmWZpPt0ymvVxbuE4FLusChsVKVDZqx1pOfXSZMTphosUW5nghoQnER6Yvi2V5paaAVFhSM/FTSu7/5YU0nffgaMFRSxsao9ds9YZV2b/4cWwveGRB07C0OKPDSYX3+NDIPBmDMM2hVLBexvS0Z0BC5bKloCFw1OFprcg=,iv:fniuutOwbeEvVObNI48TZmiv16WWYudeFMSmWo69h+g=,tag:P1z44JgBuTnXyZVCVgZwLg==,type:str] + lastmodified: "2024-08-04T00:37:58Z" + mac: ENC[AES256_GCM,data:zpPT060VGVh16KA70at4k2Q57zmT6PpYwHgGLfXLoPTu+aq3UhwQDnV/7gOUEquzopAT/lanbYjZ70uZZkXgU/HkBHNF3MLLULPK4HrOWgcsm277WPrgLqT9yUG2H8yxZGxDmKvFA7wHQ4TWyvqOmfuGv89UPoyV9PBGZ7anO6s=,iv:JtPVYsvg+2qgUlf6IF157lmorK2FrK1A6Fo15rkEnXA=,tag:iLWhUcFqY5Mip++SUZEj3Q==,type:str] pgp: - created_at: "2024-05-14T14:35:02Z" enc: |-