1# CHICKEN {#sec-chicken}
2
3[CHICKEN](https://call-cc.org/) is a
4[R⁵RS](https://schemers.org/Documents/Standards/R5RS/HTML/)-compliant Scheme
5compiler. It includes an interactive mode and a custom package format, "eggs".
6
7## Using Eggs {#sec-chicken-using}
8
9Eggs described in nixpkgs are available inside the
10`chickenPackages.chickenEggs` attrset. Including an egg as a build input is
11done in the typical Nix fashion. For example, to include support for [SRFI
12189](https://srfi.schemers.org/srfi-189/srfi-189.html) in a derivation, one
13might write:
14
15```nix
16 buildInputs = [
17 chicken
18 chickenPackages.chickenEggs.srfi-189
19 ];
20```
21
22Both `chicken` and its eggs have a setup hook which configures the environment
23variables `CHICKEN_INCLUDE_PATH` and `CHICKEN_REPOSITORY_PATH`.
24
25## Updating Eggs {#sec-chicken-updating-eggs}
26
27nixpkgs only knows about a subset of all published eggs. It uses
28[egg2nix](https://github.com/the-kenny/egg2nix) to generate a
29package set from a list of eggs to include.
30
31The package set is regenerated by running the following shell commands:
32
33```
34$ nix-shell -p chickenPackages.egg2nix
35$ cd pkgs/development/compilers/chicken/5/
36$ egg2nix eggs.scm > eggs.nix
37```
38
39## Adding Eggs {#sec-chicken-adding-eggs}
40
41When we run `egg2nix`, we obtain one collection of eggs with
42mutually-compatible versions. This means that when we add new eggs, we may
43need to update existing eggs. To keep those separate, follow the procedure for
44updating eggs before including more eggs.
45
46To include more eggs, edit `pkgs/development/compilers/chicken/5/eggs.scm`.
47The first section of this file lists eggs which are required by `egg2nix`
48itself; all other eggs go into the second section. After editing, follow the
49procedure for updating eggs.
50
51## Override Scope {#sec-chicken-override-scope}
52
53The chicken package and its eggs, respectively, reside in a scope. This means,
54the scope can be overridden to effect other packages in it.
55
56This example shows how to use a local copy of `srfi-180` and have it affect
57all the other eggs:
58
59```nix
60let
61 myChickenPackages = pkgs.chickenPackages.overrideScope' (self: super: {
62 # The chicken package itself can be overridden to effect the whole ecosystem.
63 # chicken = super.chicken.overrideAttrs {
64 # src = ...
65 # };
66
67 chickenEggs = super.chickenEggs.overrideScope' (eggself: eggsuper: {
68 srfi-180 = eggsuper.srfi-180.overrideAttrs {
69 # path to a local copy of srfi-180
70 src = ...
71 };
72 });
73 });
74in
75# Here, `myChickenPackages.chickenEggs.json-rpc`, which depends on `srfi-180` will use
76# the local copy of `srfi-180`.
77# ...
78```