~evhan/beaker

01bb45c1df12734e2cbca31f662804ac5fd54fea — Evan Hanson 6 months ago 3679375 0.0.12
Small fixes for Nix helpers and docs
2 files changed, 32 insertions(+), 19 deletions(-)

M default.nix
M nix.md
M default.nix => default.nix +6 -9
@@ 24,21 24,18 @@ rec {
        else if builtins.typeOf eggs == "list"
        then lib.concatStringsSep " " (map (egg: "${egg.name}:${egg.version}") eggs)
        else ""}
    mv $CHICKEN_EGG_CACHE $out
    rm $out/*/STATUS
    rm $out/*/TIMESTAMP
    mv -T $CHICKEN_EGG_CACHE $out
    rm -f $out/*/STATUS
    rm -f $out/*/TIMESTAMP
  '';

  eggProgram = {
    name, src,
    buildInputs ? [],
    eggCache ? null,
    preUnpack ? "",
    preBuild ? "",
    ...
  } @ args: stdenv.mkDerivation {
    name = name;
    src = src;
  } @ args: stdenv.mkDerivation ({
    buildInputs = [ chicken makeWrapper ] ++ buildInputs;

    CHICKEN_EGG_CACHE = "/build/eggs";


@@ 66,7 63,7 @@ rec {
    installPhase = ''
      runHook preInstall

      mv $CHICKEN_INSTALL_PREFIX $out
      mv -T $CHICKEN_INSTALL_PREFIX $out

      if [ -d $out/lib ]; then
        find $out/lib -type f -not -name \*.so -delete


@@ 83,5 80,5 @@ rec {

      runHook postInstall
    '';
  } // removeAttrs args [ "preUnpack" "preBuild" ];
  } // removeAttrs args [ "buildInputs" "eggCache" "preUnpack" "preBuild" ]);
}

M nix.md => nix.md +26 -10
@@ 1,16 1,16 @@
=== Usage

The helpers can be imported from the Git repository archive:
The helpers can be imported directly from the Git repository archive:

    let
      beaker = import (fetchTarball https://git.sr.ht/~evhan/beaker/archive/master.tar.gz) {};
    in
      doStuff { ... }
      doStuff { with beaker; ... }

This library only includes two attributes, so it's also relatively harmless to
pull into scope, for example:

    with import (fetchTarball https://git.sr.ht/~evhan/beaker/archive/6bfb584b.tar.gz) {};
    with import (fetchTarball https://git.sr.ht/~evhan/beaker/archive/3679375a.tar.gz) {};
    
    eggProgram {
      name = "example";


@@ 33,22 33,38 @@ can be generated via `chicken-status -list` (for installed eggs) or
`chicken-lock` (for a specific egg's dependencies).

    eggCache {
      name = "example-egg-cache"
      hash = "sha256:03pz5927dkazrf8hf53w03r80ca98fwp09gmd8iiywxc5vl8ll2m"
      eggs = ./eggs.lock
      name = "example-egg-cache";
      hash = "sha256:03pz5927dkazrf8hf53w03r80ca98fwp09gmd8iiywxc5vl8ll2m";
      eggs = ./eggs.lock;
    }

Alternatively, you can specify the list of eggs directly:

    eggCache {
      name = "example-egg-cache"
      hash = "sha256:1yrlmk6d9y71x6rirp9imrkkc1y4ph7042xchrb07dsfl6svxc6k"
      name = "example-egg-cache";
      hash = "sha256:01fq1398aj4r54yw6ym8i56i236yb3pvmn6a54iahz09cp615g2x";
      eggs = [
        { name = "srfi-18"; version = "0.1"; };
        { name = "srfi-69"; version = "0.4"; };
        { name = "srfi-18"; version = "0.1"; }
        { name = "srfi-69"; version = "0.4"; }
      ];
    }

==== Combining Multiple Egg Caches

To merge multiple egg caches, you can use `symlinkJoin`:

    pkgs.symlinkJoin {
      name = "example-egg-caches";
      paths = [
        (eggCache { ... })
        (eggCache { ... })
      ];
    }

The result will be a single egg cache containing all of the specified eggs.
Note that if any input paths contain different versions of the same egg, the
first one listed takes precedence.

=== Building Eggs

    [procedure] eggProgram attrSet