nix support for racket (experimental)
Go to file
xenia 2a52ce3a7f refactor 2025-09-29 22:00:43 -04:00
racket only wrap elf binaries and not scripts 2025-09-27 00:34:01 -04:00
.gitignore init racket at nixpkgs/f8a7597 2025-09-26 21:17:32 -04:00
README.md implement racket packaging and environments 2025-09-28 20:27:04 -04:00
build-racket-package.nix update some jank 2025-09-29 21:47:23 -04:00
flake.lock init racket at nixpkgs/f8a7597 2025-09-26 21:17:32 -04:00
flake.nix refactor 2025-09-29 22:00:43 -04:00
make-racket-env.nix update some jank 2025-09-29 21:47:23 -04:00
overlay.nix refactor 2025-09-29 22:00:43 -04:00
racket-install-hook.nix implement racket packaging and environments 2025-09-28 20:27:04 -04:00
racket-install-hook.sh update some jank 2025-09-29 21:47:23 -04:00

README.md

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

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.

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
  • split outputs or have an option to not build the docs for every package, because it can take a while and results in 20+MB of additional disk space