aboutsummaryrefslogtreecommitdiff
path: root/nix/racket-env.nix
blob: a4a86fb5b8929ca9984e1672d6e853a74b680599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{pkgs ? import <nixpkgs> {}, ...}: let
  inherit (pkgs) fetchurl fetchgit;
  racket = pkgs.racket-minimal;
  collection = pkgs.stdenv.mkDerivation {
    name = "raco-collection";
    buildInputs = [racket];
    phases = ["unpackPhase" "buildPhase"];

    src = ./racket-pkgs.tar.xz;

    buildPhase = ''
      mkdir -p /tmp/install
      for f in ./*; do
        fname=`basename $f`
        ln -s `readlink -e $f` "/tmp/install/''${fname:33}"
      done

      mkdir -p $out
      export PLTADDONDIR=$out

      raco pkg install --batch --fail-fast --no-docs -j 4 --deps force --copy /tmp/install/*
    '';
  };
in
  pkgs.stdenv.mkDerivation {
    name = "racket-wrapped";
    buildInputs = [pkgs.makeWrapper];
    phases = ["installPhase" "fixupPhase"];
    installPhase = ''
      mkdir -p $out/bin
      makeWrapper ${racket}/bin/racket $out/bin/racket \
        --set PLTADDONDIR ${collection} \
        --prefix PATH : ${pkgs.z3}/bin;
    '';
  }