racket-nix/build-racket-package.nix

74 lines
1.8 KiB
Nix

{
lib,
racket,
racketInstallHook,
stdenv,
wrapGAppsHook3,
}: lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;
excludeDrvArgNames = [
"dependencies"
"tetheredInstallation"
"doMainSetup"
"buildDocs"
"gitSubpath"
];
extendDrvArgs = finalAttrs:
{
pname,
version,
nativeBuildInputs ? [],
propagatedBuildInputs ? [],
dependencies ? [],
tetheredInstallation ? false,
doMainSetup ? tetheredInstallation,
buildDocs ? tetheredInstallation,
gitSubpath ? ".",
...
} @ attrs: {
name = "racket${racket.version}-" + pname + "-" + version;
strictDeps = true;
dontConfigure = true;
dontBuild = true;
racketTetheredInstallation = tetheredInstallation;
racketDoMainSetup = doMainSetup;
racketBuildDocs = buildDocs;
racketGitSubpath = gitSubpath;
nativeBuildInputs = [
racket
racketInstallHook
wrapGAppsHook3
] ++ nativeBuildInputs;
propagatedBuildInputs = [racket] ++ dependencies ++ propagatedBuildInputs;
dontWrapGApps = true;
preFixup = ''
find $out/bin -type f -executable -print0 |
while IFS= read -r -d ''' f; do
if test "$(file --brief --mime-type "$f")" = application/x-executable; then
wrapGApp "$f"
fi
done
'' + (lib.optionalString (!tetheredInstallation) ''
find $out/bin -type f -executable -print0 |
while IFS= read -r -d ''' f; do
if test "$(file --brief --mime-type "$f")" = text/x-shellscript; then
substituteInPlace "$f" \
--replace-fail "\"\''${bindir}/racket\"" \
"\"\''${bindir}/racket\" --config $out/etc/racket/"
fi
done
'');
};
}