From a597c66afe50dc54c4ea426497fe99e3c1d45ee5 Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Sun, 21 Jan 2018 21:24:48 +0100 Subject: [PATCH] syncthing: merge qsyncthingtray into the module --- modules/misc/news.nix | 10 ++-- modules/modules.nix | 1 - modules/services/qsyncthingtray.nix | 29 ------------ modules/services/syncthing.nix | 73 +++++++++++++++++++++-------- 4 files changed, 61 insertions(+), 52 deletions(-) delete mode 100644 modules/services/qsyncthingtray.nix diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 31ebe5526..202ab915e 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; @@ -534,9 +534,13 @@ in } { - time = "2018-01-20T10:36:12+00:00"; + time = "2018-01-25T11:35:08+00:00"; + condition = options.services.qsyncthingtray.enable.isDefined; message = '' - A new module is available: 'services.qsyncthingtray' + 'services.qsyncthingtray' has been merged into 'services.syncthing'. + Please, use 'services.syncthing.tray' option to activate the tray service. + + The old module will be removed on February 25, 2018. ''; } ]; diff --git a/modules/modules.nix b/modules/modules.nix index 529350143..7fd76147b 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -53,7 +53,6 @@ let ./services/owncloud-client.nix ./services/parcellite.nix ./services/polybar.nix - ./services/qsyncthingtray.nix ./services/random-background.nix ./services/redshift.nix ./services/screen-locker.nix diff --git a/modules/services/qsyncthingtray.nix b/modules/services/qsyncthingtray.nix deleted file mode 100644 index fb9dc2873..000000000 --- a/modules/services/qsyncthingtray.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -{ - options = { - services.qsyncthingtray = { - enable = mkEnableOption "QSyncthingTray"; - }; - }; - - config = mkIf config.services.qsyncthingtray.enable { - systemd.user.services.qsyncthingtray = { - Unit = { - Description = "QSyncthingTray"; - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; - }; - - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - - Service = { - ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; - }; - }; - }; -} diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index f722208d1..5b34d9aa5 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -3,32 +3,67 @@ with lib; { + imports = [ + (mkRenamedOptionModule + [ "services" "qsyncthingtray" "enable" ] + [ "services" "syncthing" "tray" ]) + ]; + meta.maintainers = [ maintainers.rycee ]; options = { services.syncthing = { enable = mkEnableOption "Syncthing continuous file synchronization"; - }; - }; - config = mkIf config.services.syncthing.enable { - systemd.user.services.syncthing = { - Unit = { - Description = "Syncthing - Open Source Continuous File Synchronization"; - Documentation = "man:syncthing(1)"; - After = [ "network.target" ]; - }; - - Service = { - ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; - Restart = "on-failure"; - SuccessExitStatus = [ 3 4 ]; - RestartForceExitStatus = [ 3 4 ]; - }; - - Install = { - WantedBy = [ "default.target" ]; + tray = mkOption { + type = types.bool; + default = false; + description = "Whether to enable QSyncthingTray service."; }; }; }; + + config = mkIf config.services.syncthing.enable (mkMerge [ + { + systemd.user.services = { + syncthing = { + Unit = { + Description = "Syncthing - Open Source Continuous File Synchronization"; + Documentation = "man:syncthing(1)"; + After = [ "network.target" ]; + }; + + Service = { + ExecStart = "${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"; + Restart = "on-failure"; + SuccessExitStatus = [ 3 4 ]; + RestartForceExitStatus = [ 3 4 ]; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; + } + (mkIf config.services.syncthing.tray { + systemd.user.services = { + qsyncthingtray = { + Unit = { + Description = "QSyncthingTray"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + ExecStart = "${pkgs.qsyncthingtray}/bin/QSyncthingTray"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; + }) + ]); }