~evhan/beaker

3679375a8efe39d4cecd26d5ea483dc00927c84a — Evan Hanson 6 months ago 49dd595
Extend `eggCache` to allow specifying eggs directly
4 files changed, 35 insertions(+), 13 deletions(-)

M beaker.wiki.in
M chicken-lock.scm
M default.nix
M nix.md
M beaker.wiki.in => beaker.wiki.in +3 -0
@@ 45,6 45,9 @@ The project's source is available [[https://git.sr.ht/~evhan/beaker|here]].

== Nix Helpers

This project also includes some helper functions for the [[https://nixos.org/|Nix]]
package manager that make it easy to build CHICKEN programs.

#(with-input-from-file "nix.md" read-string)

== Links

M chicken-lock.scm => chicken-lock.scm +1 -1
@@ 18,7 18,7 @@
;;
;;     $ chicken-lock r7rs > r7rs.lock
;;     ... time passes...
;;     $ chicken-install -override r7rs.lock r7rs
;;     $ chicken-install -from-list r7rs.lock
;;
;; If no egg names are given on the command line, this program will look for
;; egg files in the current directory. This can be used to record the current

M default.nix => default.nix +11 -3
@@ 7,15 7,23 @@ rec {

  eggCache = {
    name ? "eggs",
    hash,
    overrideFile,
    eggs, hash,
    includeDependencies ? true,
    includeTestDependencies ? false,
  }: runCommand name {
    buildInputs = [ chicken ];
    outputHash = hash;
    outputHashMode = "recursive";
    CHICKEN_EGG_CACHE = "eggs";
  } ''
    chicken-install -retrieve -recursive -from-list ${overrideFile}
    chicken-install -retrieve \
      ${lib.optionalString (includeDependencies) "-recursive"} \
      ${lib.optionalString (includeTestDependencies) "-test"} \
      ${if builtins.typeOf eggs == "path"
        then "-from-list ${eggs}"
        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

M nix.md => nix.md +20 -9
@@ 1,14 1,14 @@
=== Usage

This library's Nix helpers can be imported from the Git repository archive:
The helpers can be imported from the Git repository archive:

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

The project's `default.nix` only includes two helpers so it's also relatively
harmless to pull into scope, for example:
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) {};
    


@@ 16,7 16,7 @@ harmless to pull into scope, for example:
      name = "example";
      src = ./.;
      eggCache = eggCache {
        overrideFile = ./example.egg.lock;
        eggs = ./example.egg.lock;
        hash = "sha256:00x5k7rhs1fy7fj5kma1yp2ikzbq98bfm33si5y8z8m25chb45sg";
      };
    }


@@ 27,15 27,26 @@ harmless to pull into scope, for example:

A fixed-output derivation that fetches a set of eggs for installation.

The list of eggs to cache should be specified via `overrideFile`, which
expects a path to a file in "override" specifying a list of egg names and
versions. This file can be generated via `chicken-status -list` (for installed
eggs) or `chicken-lock` (for a specific egg's dependencies).
The list of eggs to cache should be specified via `eggs`, which expects a path
to a file in "override" specifying a list of egg names and versions. This file
can be generated via `chicken-status -list` (for installed eggs) or
`chicken-lock` (for a specific egg's dependencies).

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

Alternatively, you can specify the list of eggs directly:

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

=== Building Eggs