mirror of
https://git.sr.ht/~bryan_bennett/flake_env
synced 2025-12-16 14:41:24 +01:00
Core doubles the closure size and adds 8mb to the binary size for dubious benefit. This adds FileUtils to do the file interaction bits that aren't in the stdlib and removes Core in preference to the bundled Stdlib. Tests are passing, but I want to investigate the nix build before I commit to this approach
68 lines
1.4 KiB
Nix
68 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 = ''
|
|
${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;
|
|
};
|
|
}
|