summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/gitignore.nix
blob: b3c750a087e397cc43261e45e1c27b07315d0919 (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
38
39
40
41
42
43
44
45
46
{ pkgs }:

/* gitignore - Filter for intentionally untracked lines or blocks of code

This is a filter that allows specifying intentionally untracked lines and
blocks of code that Git should ignore.

Example:

  int main(void) {
    printf("I would never say derp.\n");
    //#gitignore-begin
    printf("DERP!\n");
    //#gitignore-end
    printf("DERP!\n"); //#gitignore
    return 0;
  }

Installation:

  Define a filter, e.g. in ~/.config/git/config[1]:

      [filter "gitignore"]
        clean = gitignore
        smudge = cat

  Assing that filter to some paths, e.g. in ~/.config/git/attributes[2]:

      *.hs filter=gitignore
      *.c filter=gitignore
      ...

  [1]: For more information about defining filters see git-config(1).
  [2]: For more information about assigning filters see gitattributes(5).
*/

pkgs.execBin "gitignore" {
  filename = "${pkgs.gnused}/bin/sed";
  argv = [
    "gitignore"
    /* sed */ ''
      /#gitignore-begin/,/#gitignore-end/d
      /#gitignore/d
    ''
  ];
}