summaryrefslogtreecommitdiff
path: root/pkgs/static/gitignore/default.nix
blob: 6ee8649c32a4a76c2fb6a9c40f98047426e4a340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
  templates ? [ ],
  toUncomment ? [ ],
  stdenvNoCC,
  fetchFromGitHub,
  lib,
}:
stdenvNoCC.mkDerivation {
  name = lib.concatStringsSep "+" templates + ".gitignore";
  version = "2025-07-20";

  src = fetchFromGitHub {
    owner = "github";
    repo = "gitignore";
    rev = "9c2e50c7ccbf2f367f44e3c93e83934d12d67611";
    hash = "sha256-Zo0eOiCH6NWSjO1mm8KhoNDxQePb15dVKhxvQ62alyQ=";
  };

  buildPhase = ''
    mv {Global,community}/*.gitignore .
    for file in ${
      lib.concatStringsSep " " (builtins.map (name: lib.escapeShellArg "${name}.gitignore") templates)
    }
    do
      echo "### $(basename "$file" .gitignore)" >> $out
      cat "$file" >> $out
      echo >> $out
    done
    substituteInPlace $out ${
      lib.concatStringsSep " " (
        builtins.map (
          line: "--replace ${lib.escapeShellArg "# ${line}"} ${lib.escapeShellArg line}"
        ) toUncomment
      )
    }
  '';
}