git: add basic support for LFS

Fixes #542

(cherry picked from commit 1cdb8abf30)
This commit is contained in:
Robert Helgesson 2019-02-03 23:54:29 +01:00
parent fdb81a7ea0
commit ee7631fbe3
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 40 additions and 0 deletions

View file

@ -133,6 +133,20 @@ in
''; '';
description = "List of configuration files to include."; description = "List of configuration files to include.";
}; };
lfs = {
enable = mkEnableOption "Git Large File Storage";
skipSmudge = mkOption {
type = types.bool;
default = false;
description = ''
Skip automatic downloading of objects on clone or pull.
This requires a manual <command>git lfs pull</command>
every time a new commit is checked out on your repository.
'';
};
};
}; };
}; };
@ -204,6 +218,25 @@ in
'') '')
cfg.includes); cfg.includes);
}) })
(mkIf cfg.lfs.enable {
home.packages = [ pkgs.git-lfs ];
programs.git.iniContent."filter \"lfs\"" =
let
skipArg = optional cfg.lfs.skipSmudge "--skip";
in
{
clean = "git-lfs clean -- %f";
process = concatStringsSep " " (
[ "git-lfs" "filter-process" ] ++ skipArg
);
required = true;
smudge = concatStringsSep " " (
[ "git-lfs" "smudge" ] ++ skipArg ++ [ "--" "%f" ]
);
};
})
] ]
); );
} }

View file

@ -10,6 +10,12 @@ boolean=true
integer=38 integer=38
name=value name=value
[filter "lfs"]
clean=git-lfs clean -- %f
process=git-lfs filter-process
required=true
smudge=git-lfs smudge -- %f
[gpg] [gpg]
program=path-to-gpg program=path-to-gpg

View file

@ -31,6 +31,7 @@ with lib;
}; };
userEmail = "user@example.org"; userEmail = "user@example.org";
userName = "John Doe"; userName = "John Doe";
lfs.enable = true;
} }
{ {