From 477887dc1cb630cd1d006b99bbe0187f644cc7e1 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Wed, 10 Aug 2022 13:15:34 +0200 Subject: [PATCH] add initial nextcloud module --- modules/nextcloud.nix | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 modules/nextcloud.nix diff --git a/modules/nextcloud.nix b/modules/nextcloud.nix new file mode 100644 index 00000000..fb501c1e --- /dev/null +++ b/modules/nextcloud.nix @@ -0,0 +1,44 @@ +# Changed from https://github.com/nix-community/home-manager/blob/master/modules/services/nextcloud-client.nix +# I use this instead of the HM module as the autostart wasn't working there + +{ config, lib, mylib, pkgs, ... }: + +with lib; +with mylib.modules; + +let + cfg = config.modules.nextcloud; +in { + options.modules.nextcloud = { + enable = mkEnableOpt "Nextcloud Client"; + autostart = mkBoolOpt false "Autostart the Nextcloud client (systemd)"; + }; + + config = mkIf cfg.enable { + assertions = [ + { + assertion = !config.home.services.nextcloud-client.enable; + message = "Can't enable both HM nextcloud and my nextcloud module!"; + } + ]; + # I want to have nextcloud-client in the path when the module is enabled + home.packages = with pkgs; [ nextcloud-client ]; + + systemd.user.services = (mkIf cfg.autostart) { + autostart-nextcloud-client = { + Unit = { + Description = "Nextcloud Client"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; # was graphical-session-pre.target originally in HM + }; + + Service = { + Environment = "PATH=${config.home.profileDirectory}/bin"; + ExecStart = "${pkgs.nextcloud-client}/bin/nextcloud"; + }; + + Install.WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} \ No newline at end of file