git-check-assertions/default.nix

75 lines
1.2 KiB
Nix

{
stdenv,
lib,
git,
gnused,
bash,
bats,
shellcheck-minimal,
gitMinimal,
resholve,
}:
let
fs = lib.fileset;
in
resholve.mkDerivation {
pname = "git-check-assertions";
version = "0.0.1";
src = fs.toSource {
root = ./.;
fileset = fs.unions [
./bin/git-check-assertions
./test.bats
];
};
postPatch = ''
patchShebangs .
'';
nativeCheckInputs = [
shellcheck-minimal
bats
gitMinimal
];
checkPhase = ''
runHook preCheck
shellcheck bin/git-check-assertions test.bats
git init
git config user.email test
git config user.name test
git checkout -b main
git commit --allow-empty -m "initial"
./test.bats
runHook postCheck
'';
doCheck = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp $src/bin/git-check-assertions $out/bin/git-check-assertions
runHook postInstall
'';
solutions.default = {
scripts = [ "bin/git-check-assertions" ];
interpreter = lib.getExe bash;
inputs = [
gitMinimal
gnused
bash
];
execer = [
# Not true at all, but ¯\_(ツ)_/¯
"cannot:${lib.getExe bash}"
"cannot:${lib.getExe gitMinimal}"
];
};
meta.mainProgram = "git-check-assertions";
}