diff --git a/nixos/modules/programs/git.nix b/nixos/modules/programs/git.nix index 90857863f69e..b9a4bb772df6 100644 --- a/nixos/modules/programs/git.nix +++ b/nixos/modules/programs/git.nix @@ -84,6 +84,20 @@ in enablePureSSHTransfer = lib.mkEnableOption "Enable pure SSH transfer in server side by adding git-lfs-transfer to environment.systemPackages"; }; + + attributes = lib.mkOption { + type = lib.types.lines; + default = ""; + example = "*.pdf diff=pdf"; + description = '' + Assign git attributes to files (one pattern per line): + + PATTERN1 ATTR1 ATTR2 ... + + Blank lines and lines beginning with # are ignored. See + {manpage}`gitattributes(5)` for more information. + ''; + }; }; }; @@ -93,6 +107,10 @@ in environment.etc.gitconfig = lib.mkIf (cfg.config != [ ]) { text = lib.concatMapStringsSep "\n" lib.generators.toGitINI cfg.config; }; + + environment.etc.gitattributes = lib.mkIf (cfg.attributes != "") { + text = cfg.attributes + "\n"; + }; }) (lib.mkIf (cfg.enable && cfg.lfs.enable) { environment.systemPackages = lib.mkMerge [