Files
nixpkgs/pkgs/development/compilers/chicken/common/eggDerivation.nix
Christopher Harrison 48dbd6c931 chickenPackages.eggDerivation: drop the egg repository from the wrapper PATH
CHICKEN_REPOSITORY_PATH is a search path of egg repository directories, which
hold compiled modules and .egg-info files, not executables, so prefixing PATH
with it never made a program findable.  It also bakes the build time
repository search path, i.e. the egg's own build inputs, into the wrapper of
every installed program.

Reported by @DerGuteMoritz in review, who verified it with the csm egg; csm
still runs with the prefix removed, on both CHICKEN 5 and 6.

Assisted-by: Claude Code (claude-opus-5[1m])
2026-09-10 19:20:46 +01:00

109 lines
3.1 KiB
Nix

{
callPackage,
lib,
stdenv,
chicken,
makeWrapper,
# Release-specific arguments, supplied by the per-release directory.
overridesFile,
}:
{
src,
buildInputs ? [ ],
chickenInstallFlags ? [ ],
cscOptions ? [ ],
...
}@args:
let
nameVersionAssertion =
pred: lib.assertMsg pred "either name or both pname and version must be given";
pname =
if args ? pname then
assert nameVersionAssertion (!args ? name && args ? version);
args.pname
else
assert nameVersionAssertion (args ? name && !args ? version);
lib.getName args.name;
version = if args ? version then args.version else lib.getVersion args.name;
overrides = callPackage overridesFile { };
override = if builtins.hasAttr pname overrides then builtins.getAttr pname overrides else lib.id;
in
(stdenv.mkDerivation (
{
pname = "chicken-${pname}";
inherit version;
propagatedBuildInputs = buildInputs;
nativeBuildInputs = [
chicken
makeWrapper
];
buildInputs = [ chicken ];
strictDeps = true;
env = {
CSC_OPTIONS = lib.concatStringsSep " " cscOptions;
}
// (args.env or { });
buildPhase = ''
runHook preBuild
# From CHICKEN 6 on, chicken-install takes a lock in its egg cache even
# when building an egg from the current directory, and the cache defaults
# to a location under HOME, which is not writable in the sandbox. The
# cache itself stays empty: with -cached, chicken-install builds the
# unpacked egg in place. The install phase runs in the same shell, so it
# inherits this.
export CHICKEN_EGG_CACHE="$NIX_BUILD_TOP/chicken-egg-cache"
mkdir -p "$CHICKEN_EGG_CACHE"
chicken-install -cached -no-install -host ${lib.escapeShellArgs chickenInstallFlags}
runHook postBuild
'';
installPhase = ''
runHook preInstall
export CHICKEN_INSTALL_PREFIX=$out
export CHICKEN_INSTALL_REPOSITORY=$out/lib/chicken/${toString chicken.binaryVersion}
chicken-install -cached -host ${lib.escapeShellArgs chickenInstallFlags}
# Patching the generated .egg-info instead of the original .egg to work
# around https://bugs.call-cc.org/ticket/1855, which is unfixed as of
# CHICKEN 6.0.0: eggs whose .egg carries no version property are
# installed without one.
csi -e "(write (cons '(version \"${version}\") (read)))" < "$CHICKEN_INSTALL_REPOSITORY/${pname}.egg-info" > "${pname}.egg-info.new"
mv "${pname}.egg-info.new" "$CHICKEN_INSTALL_REPOSITORY/${pname}.egg-info"
for f in $out/bin/*
do
wrapProgram $f \
--prefix CHICKEN_REPOSITORY_PATH : "$out/lib/chicken/${toString chicken.binaryVersion}:$CHICKEN_REPOSITORY_PATH" \
--prefix CHICKEN_INCLUDE_PATH : "$CHICKEN_INCLUDE_PATH:$out/share" \
--prefix PATH : "$out/bin:${chicken}/bin"
done
runHook postInstall
'';
dontConfigure = true;
meta = {
inherit (chicken.meta) platforms;
}
// args.meta or { };
}
// removeAttrs args [
"name"
"pname"
"version"
"buildInputs"
"meta"
]
)).overrideAttrs
override