racket-nix/README.md

63 lines
2.0 KiB
Markdown

# nix support for racket
implements nix helpers for building racket packages and environments
this is a complete new implementation of this functionality. i did not use racket2nix because
racket2nix is messy and hasn't been updated for a while. this is a significantly simpler
implementation owning to better use of stdenv utilities and racket features
## how to use
### make nix packages for racket packages
```nix
pkgs.racketPackages.callPackage (
{
lib,
buildRacketPackage,
fetchFromGitHub,
}: buildRacketPackage {
pname = "ansi-color";
version = "0.2";
src = final.fetchFromGitHub {
owner = "renatoathaydes";
repo = "ansi-color";
rev = "0.2";
hash = "sha256-7WDW+4R9K+XLb9nMNGQlU+zAi2Gq7cUqzO3csN+AJvI=";
};
}
) {}
```
### build a racket environment
unfortunately, due to racket limitations, `nix-shell`/`nix develop` will not work at all for racket
packages that are created using this nix code. instead, similar to `python.buildEnv` /
`python.withPackages`, you can create a racket environment with a given set of packages in it. this
functions somewhat like a python "virtualenv" for racket. it is implemented by creating a "tethered
installation" -- see <https://docs.racket-lang.org/raco/tethered-install.html>.
```nix
with pkgs.racketPackages; makeRacketEnv {
packages = [
ansi-color
];
};
```
the resulting environment will have a `bin/racket` executable which has the declared packages
available
## future work
- automatically convert info.rkt into packaging. this should be doable for most of the catalog that
is currently building on the CI, and perhaps some additional steps are needed for native library
dependencies declared in info.rkt
- allow using either racket or racket-minimal as a base (currently only racket non-minimal is
supported)
- instead of having 2 separate packages, rework racket to be a layered installation on top of
racket-minimal, reducing duplication. this is similar to how guix does it