~evhan/beaker

f049bece3ce9cd96f9f6bf3610a9a3813e22bdbc — Evan Hanson 9 months ago 43a9298
Avoid file collisions among eggPrograms that use the same eggs
2 files changed, 14 insertions(+), 13 deletions(-)

M default.nix
M nix.md
M default.nix => default.nix +7 -7
@@ 2,9 2,7 @@

with pkgs;

let
  repositoryPath = "lib/chicken/${toString chicken.binaryVersion}";
in rec {
rec {
  eggCache = {
    name ? "eggs",
    eggs, hash,


@@ 35,10 33,11 @@ in rec {
    eggCache ? src,
    buildInputs ? [],
    shellHook ? "",
    repositoryPath ? "lib/chicken/${toString chicken.binaryVersion}",
    ...
  } @ args:
  let
    isEgg = with builtins; f: pathExists "${eggCache}/${f}/VERSION";
    isEgg = with builtins; file: pathExists "${eggCache}/${file}/VERSION";
    cachedEggs = with builtins; filter isEgg (attrNames (readDir eggCache));
    setupEnvironmentPhase = ''
      export CHICKEN_EGG_CACHE=$TMPDIR/cache


@@ 119,13 118,14 @@ in rec {
  eggProgram = {
    name,
    postInstall ? "",
    repositoryPath ? "lib/${name}",
    ...
  } @ args: eggRepository (args // {
    inherit name;
    inherit name repositoryPath;

    postInstall = ''
      if [ -d $out/lib ]; then
        find $out/lib -type f -not -name \*.so -delete
      if [ -d $out/${repositoryPath} ]; then
        find $out/${repositoryPath} -type f -not -name \*.so -delete
      fi
    '' + postInstall;
  });

M nix.md => nix.md +7 -6
@@ 121,10 121,11 @@ the same attributes as `eggRepository`.
      eggCache = eggCache { ... };
    }

Unlike `eggRepository`, this derivation only includes shared object files in
the repository path. This means that all `egg-info`, `inline` and `link` files
are removed, making the result unsuitable for use in the `builtInputs` of
another `eggProgram`. It should only be used to create executables, not
Unlike `eggRepository`, this derivation only preserves shared object files in
the repository path, and it does not expose the output repository to
downstream derivations. This means that all `egg-info`, `inline` and `link`
files are removed, making the result unsuitable for use in the `builtInputs`
of another `eggProgram`. It should only be used to create executables, not
extension repositories.

Combining the `eggRepository` and `eggProgram` derivations is useful to stage


@@ 147,8 148,8 @@ whenever the current source directory changes.
==== Linking With External Libraries

When linking to external libraries, it's usually enough to use
`buildInputs`. This can either be done when compiling the egg itself, or
when building a program that uses the egg sources.
`buildInputs`. For eggs, this can either be done when compiling the egg
itself, or when building a program that uses the cached egg from source.

For example, to build a program using the openssl egg, you can either
build the program and its dependencies (including the OpenSSL library)