From 0e9e86b1794c1003db38ee77437b2522d700174e Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 6 Dec 2022 17:21:08 +0100 Subject: [PATCH] megasync: add module --- .github/CODEOWNERS | 2 ++ modules/misc/news.nix | 8 +++++++ modules/modules.nix | 1 + modules/services/megasync.nix | 40 +++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 modules/services/megasync.nix diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dbeca9f1..22c23275 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -427,6 +427,8 @@ Makefile @thiagokokada /modules/services/mbsync.nix @pjones +/modules/services/megasync.nix @GaetanLepage + /modules/services/mopidy.nix @foo-dogsquared /tests/modules/services/mopidy @foo-dogsquared diff --git a/modules/misc/news.nix b/modules/misc/news.nix index f728be44..79229dc4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -853,6 +853,14 @@ in 'Host' blocks ''; } + + { + time = "2022-12-16T15:01:20+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'services.megasync'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index a57925ea..a96fae90 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -238,6 +238,7 @@ let ./services/lorri.nix ./services/mako.nix ./services/mbsync.nix + ./services/megasync.nix ./services/mopidy.nix ./services/mpd.nix ./services/mpdris2.nix diff --git a/modules/services/megasync.nix b/modules/services/megasync.nix new file mode 100644 index 00000000..c519ba51 --- /dev/null +++ b/modules/services/megasync.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.megasync; + +in { + meta.maintainers = [ maintainers.GaetanLepage ]; + + options = { + services.megasync = { + enable = mkEnableOption "Megasync client"; + + package = mkPackageOption pkgs "megasync" { }; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "services.megasync" pkgs + lib.platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + systemd.user.services.megasync = { + Unit = { + Description = "megasync"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { ExecStart = "${cfg.package}/bin/megasync"; }; + }; + }; +}