git: add basic support for LFS

Fixes #542
This commit is contained in:
Robert Helgesson 2019-02-03 23:54:29 +01:00
parent fbdb5beb59
commit 1cdb8abf30
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.";
};
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);
})
(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
name=value
[filter "lfs"]
clean=git-lfs clean -- %f
process=git-lfs filter-process
required=true
smudge=git-lfs smudge -- %f
[gpg]
program=path-to-gpg

View File

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