From c718951e97bdae546da977f1141c37cefb741006 Mon Sep 17 00:00:00 2001
From: Florian Klink <flokli@flokli.de>
Date: Sun, 12 Nov 2017 13:28:12 +0100
Subject: [PATCH] git: add option 'programs.git.ignores'

This allows the global Git ignores to be configured.
---
 modules/programs/git.nix | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/modules/programs/git.nix b/modules/programs/git.nix
index 3c07e799..ed43e53e 100644
--- a/modules/programs/git.nix
+++ b/modules/programs/git.nix
@@ -76,6 +76,13 @@ in
         type = types.attrsOf types.attrs;
         internal = true;
       };
+
+      ignores = mkOption {
+        type = types.listOf types.str;
+        default = [];
+        example = [ "*~" "*.swp" ];
+        description = "List of paths that should be globally ignored.";
+      };
     };
   };
 
@@ -89,8 +96,13 @@ in
           email = cfg.userEmail;
         };
 
-        xdg.configFile."git/config".text =
-          generators.toINI {} cfg.iniContent;
+        xdg.configFile = {
+          "git/config".text = generators.toINI {} cfg.iniContent;
+
+          "git/ignore" = mkIf (cfg.ignores != []) {
+            text = concatStringsSep "\n" cfg.ignores + "\n";
+          };
+        };
       }
 
       (mkIf (cfg.signing != null) {