flake_env/default.nix

69 lines
1.4 KiB
Nix

{ alcotest
, bintools
, bisect_ppx
, buildDunePackage
, fileutils
, lib
, nix-filter
, ppx_yojson_conv
, ppx_yojson_conv_lib
, re
, reason
, sha
, shellcheck
, upx
,
}:
buildDunePackage {
pname = "flake_env";
version = "0.1";
src = nix-filter {
root = ./.;
include = [
"bin"
"lib"
"tests"
./dune-project
./flake.nix
./default.nix
./flake.lock
./flake_env.opam
./direnvrc
];
};
duneVersion = "3";
doCheck = true;
# We strip by hand before packing
dontStrip = true;
# patchELF can't handle UPX'd binaries
# We produce a static OCaml binary that
dontPatchELF = true;
postCheck = ''
${shellcheck}/bin/shellcheck direnvrc
'';
postPatch = ''
substituteInPlace direnvrc --replace-fail "@flake_env@" "$out/bin/flake_env"
'';
postInstall = ''
rm -r $out/lib
${bintools}/bin/strip --strip-unneeded $out/bin/flake_env
${upx}/bin/upx $out/bin/flake_env
install -m444 -D direnvrc $out/share/flake_env/direnvrc
'';
buildInputs = [
fileutils
ppx_yojson_conv
ppx_yojson_conv_lib
re
sha
];
checkInputs = [ alcotest bisect_ppx ];
nativeBuildInputs = [ reason ];
meta = with lib; {
description = "Yet another flake plugin for direnv";
homepage = "https://git.sr.ht/~bryan_bennett/flake_env";
license = licenses.mit;
platforms = platforms.unix;
};
}