summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2023-10-20 17:07:07 +0200
committerLinnnus <[email protected]>2023-10-20 17:11:34 +0200
commit6244eec2e33843ff20a5291613cd889c19b594f7 (patch)
treec8110a573983169bf63ae05d8374c2c154b7c8e9
parent989c8b5415a2564495779207af60c5f1e9b5efca (diff)
Gitignore basic files
-rw-r--r--home/git/default.nix2
-rw-r--r--home/git/ignore.nix37
2 files changed, 39 insertions, 0 deletions
diff --git a/home/git/default.nix b/home/git/default.nix
index c950a94..68e0a25 100644
--- a/home/git/default.nix
+++ b/home/git/default.nix
@@ -6,6 +6,8 @@
inherit (lib.modules) mkIf;
inherit (pkgs.stdenv.hostPlatform) isDarwin;
in {
+ imports = [./ignore.nix];
+
programs.git = {
enable = true;
diff --git a/home/git/ignore.nix b/home/git/ignore.nix
new file mode 100644
index 0000000..8d1da2f
--- /dev/null
+++ b/home/git/ignore.nix
@@ -0,0 +1,37 @@
+# This module defines the contents of `~/.config/git/ignore`. It fetches the
+# templates for different gitignores and compiles them into one.
+{
+ pkgs,
+ lib,
+ ...
+}: let
+ gitignore = ignores:
+ pkgs.stdenv.mkDerivation {
+ name = (lib.concatStringsSep "+" ignores) + ".gitignore";
+
+ src = pkgs.fetchFromGitHub {
+ owner = "toptal";
+ repo = "gitignore";
+ rev = "7e72ecd8af69b39c25aedc645117f0dc261cedfd";
+ hash = "sha256-Ln3w6wx+pX4UFLY2gGJGax2/nxgp/Svrn0uctSIRdEc=";
+ };
+
+ inherit ignores;
+ buildPhase = ''
+ for i in $ignores; do
+ cat ./templates/$i.gitignore >>$out
+ done
+ '';
+ };
+
+ targets =
+ [
+ "Node"
+ "Deno"
+ "C"
+ ]
+ ++ (lib.optional pkgs.stdenv.isDarwin "MacOS")
+ ++ (lib.optional pkgs.stdenv.isLinux "Linux");
+in {
+ xdg.configFile."git/ignore".source = gitignore targets;
+}