From aa69598b5742024ebaee0c861585269f77ef1a5f Mon Sep 17 00:00:00 2001
From: Nikita Uvarov <uv.nikita@gmail.com>
Date: Wed, 13 Sep 2017 13:31:10 +0200
Subject: [PATCH] compton: add module

---
 modules/default.nix          |  1 +
 modules/misc/news.nix        |  7 +++++++
 modules/services/compton.nix | 29 +++++++++++++++++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 modules/services/compton.nix

diff --git a/modules/default.nix b/modules/default.nix
index 03ab0764b..115a144cf 100644
--- a/modules/default.nix
+++ b/modules/default.nix
@@ -35,6 +35,7 @@ let
     ./programs/vim.nix
     ./programs/zsh.nix
     ./services/blueman-applet.nix
+    ./services/compton.nix
     ./services/dunst.nix
     ./services/gnome-keyring.nix
     ./services/gpg-agent.nix
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 43baa1b4e..791dc0610 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -178,6 +178,13 @@ in
           A new service is available: 'services.blueman-applet'.
         '';
       }
+
+      {
+        time = "2017-09-13T11:30:22+00:00";
+        message = ''
+          A new service is available: 'services.compton'.
+        '';
+      }
     ];
   };
 }
diff --git a/modules/services/compton.nix b/modules/services/compton.nix
new file mode 100644
index 000000000..e1c349971
--- /dev/null
+++ b/modules/services/compton.nix
@@ -0,0 +1,29 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+{
+  options = {
+    services.compton = {
+      enable = mkEnableOption "Compton X11 compositor";
+    };
+  };
+
+  config = mkIf config.services.compton.enable {
+    systemd.user.services.compton = {
+        Unit = {
+          Description = "Compton X11 compositor";
+          After = [ "graphical-session-pre.target" ];
+          PartOf = [ "graphical-session.target" ];
+        };
+
+        Install = {
+          WantedBy = [ "graphical-session.target" ];
+        };
+
+        Service = {
+          ExecStart = "${pkgs.compton}/bin/compton";
+        };
+    };
+  };
+}