nix-helpers: 8772142e7081eeda953825f6a76ec7a1b6151b93
1: { lib, makeWrapper, racket, runCommand }:
2:
3: with {
4: go = { racket, name ? "${racket.name}-with-deps" }:
5: deps:
6: runCommand name {
7: inherit deps racket;
8: buildInputs = [ makeWrapper racket ];
9: } ''
10: # raco writes to HOME, so make sure that's included
11: export HOME="$out/etc"
12: mkdir -p "$HOME"
13:
14: # Each PKG should be a directory (e.g. pulled from git) containing
15: # "collections" as sub-directories. For example if PKG should allow
16: # (require utils/printing), it should contain PKG/utils/printing.rkt
17:
18: # Collect up all packages
19: mkdir -p "$out/share/pkgs"
20: for PKG in $deps
21: do
22: cp -r "$PKG" "$out/share/pkgs/"
23: done
24:
25: # Make our copies mutable, so we can compile them in-place
26: chmod +w -R "$out/share/pkgs"
27:
28: # Register packages with raco
29: for PKG in "$out/share/pkgs/"*
30: do
31: # raco is Racket's package manager, -D says "treat as a directory of
32: # collections", which is how git repos seem to be arranged.
33: raco link --user -D "$PKG"
34: done
35:
36: # Compile registered packages
37: raco setup --avoid-main -x -D
38:
39: # Provide Racket binaries patched to use our modified HOME
40: mkdir -p "$out/bin"
41: for PROG in "$racket"/bin/*
42: do
43: NAME=$(basename "$PROG")
44: makeWrapper "$PROG" "$out/bin/$NAME" --set HOME "$out/etc"
45: done
46: '';
47: };
48: lib.makeOverridable go { inherit racket; }
Generated by git2html.