From 76046850fe56efde474778db0f04493bee4222e1 Mon Sep 17 00:00:00 2001
From: "Ricardo M. Correia" <rcorreia@wizy.org>
Date: Thu, 23 May 2013 11:04:07 +0000
Subject: [PATCH] atop: Add basic config option for /etc/atoprc

---
 modules/module-list.nix   |  1 +
 modules/programs/atop.nix | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 modules/programs/atop.nix

diff --git a/modules/module-list.nix b/modules/module-list.nix
index b6193b191314..476983b33044 100644
--- a/modules/module-list.nix
+++ b/modules/module-list.nix
@@ -36,6 +36,7 @@
   ./misc/nixpkgs.nix
   ./misc/passthru.nix
   ./misc/version.nix
+  ./programs/atop.nix
   ./programs/bash/bash.nix
   ./programs/bash/command-not-found.nix
   ./programs/blcr.nix
diff --git a/modules/programs/atop.nix b/modules/programs/atop.nix
new file mode 100644
index 000000000000..7fdaab9d67df
--- /dev/null
+++ b/modules/programs/atop.nix
@@ -0,0 +1,36 @@
+# Global configuration for atop.
+
+{config, pkgs, ...}:
+
+with pkgs.lib;
+
+let cfg = config.programs.atop;
+
+in
+{
+  ###### interface
+
+  options = {
+
+    programs.atop = {
+
+      settings = mkOption {
+        type = types.attrs;
+        default = {};
+        example = {
+          flags = "a1f";
+          interval = 5;
+        };
+        description = ''
+          Parameters to be written to <filename>/etc/atoprc</filename>
+        '';
+      };
+
+    };
+  };
+
+  config = mkIf (cfg.settings != {}) {
+    environment.etc."atoprc".text =
+      concatStrings (mapAttrsToList (n: v: "${n} ${toString v}\n") cfg.settings);
+  };
+}