Skip to content

Commit

Permalink
Replace git lfs ls-files with an evaluation-time extraction from .g…
Browse files Browse the repository at this point in the history
…itattributes
  • Loading branch information
ryantrinkle committed Jan 22, 2024
1 parent 79f0e76 commit 094601e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,18 @@
udev
];
};
default = pkgs.stdenv.mkDerivation rec {
default =
let # exampleLfsPath is a path to a file managed by Git LFS. We
# grab this here so we can sanity-check whether the user has
# gotten *any* LFS files. We can't get this path during the
# build, because git metadata has already been removed by
# then.
exampleLfsPath =
builtins.elemAt (
builtins.match "(|.*\n)([^ ]*).* merge=lfs .*" (
builtins.readFile ./.gitattributes
)) 1;
in pkgs.stdenv.mkDerivation rec {
name = "little-buddy";
src = ./.;
nativeBuildInputs = with pkgs; [
Expand All @@ -117,7 +128,7 @@
xxd
];
postUnpack = ''
if [ "$(head -c 7 $(git lfs ls-files --name-only | head -1))" =! "version" ]; then
if [ "$(head -c 7 */${exampleLfsPath})" = "version" ]; then
echo "ERROR: run 'git lfs pull' to resolve binary files"
exit 1
fi
Expand Down

0 comments on commit 094601e

Please sign in to comment.