summaryrefslogtreecommitdiff
path: root/pkgs/static/gitignore/default.nix
blob: d97dec5848c6b7c75a65318a774288dc7c40dfde (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
{
  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)}
  '';
}