Created
September 6, 2021 14:23
-
-
Save lukego/966e722cef988246882413a7dc4c6948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env nix-shell | |
| #! nix-shell bootstrap.nix --run generate | |
| # This script uses ql2nix to generate dependency definitions as Nix | |
| # expressions in the current directory. Quicklisp and all packages are | |
| # installed in a temporary directory. | |
| # Quicklisp packages default root set. | |
| let default-packages = [ | |
| "1am" | |
| "alexandria" | |
| "bordeaux-threads" | |
| "cffi" | |
| "check-it" | |
| # "mcclim" | |
| # "climacs" | |
| # "clim-widgets" | |
| "cl-dot" | |
| "cl-ppcre" | |
| "cl-csv" | |
| "cl-digraph" | |
| "cl-fad" | |
| "cl-geometry" | |
| "cl-interpol" | |
| "cl-json" | |
| "cl-pdf" | |
| "cl-ppcre" | |
| "cl-svg" | |
| "cl-who" | |
| "classowary" | |
| "defclass-std" | |
| "esrap" | |
| "generic-cl" | |
| # Selection of data structures | |
| "heap" "cl-heap" "minheap" "binomial-heap" | |
| "split-sequence" | |
| "serapeum" | |
| "smug" | |
| "vecto" | |
| "flexi-streams" | |
| "physical-quantities" | |
| "named-readtables" | |
| "parachute" | |
| "trivia" | |
| "trivial-shell" | |
| "uiop" | |
| "cl-smt-lib" | |
| "lparallel" | |
| # "screamer" | |
| "binpack" | |
| # "cl-sat.minisat" | |
| # "cl-sat.glucose" | |
| # "cl-prolog2" | |
| # "gsll" | |
| # "gendl-devo" | |
| # "quicklisp" | |
| "fiveam" | |
| "jsown" | |
| "sycamore" | |
| "trees" | |
| # mgl dependencies | |
| "array-operations" | |
| # "lla" | |
| "cl-reexport" | |
| "osicat" | |
| "cl-pattern" | |
| "ironclad" | |
| ]; in | |
| { | |
| pkgs ? import ../nix/packages.nix, | |
| quicklisp-packages ? default-packages | |
| }: | |
| with pkgs; | |
| let | |
| ql2nix-srcx = fetchFromGitHub { | |
| owner = "lukego"; | |
| repo = "ql2nix"; | |
| rev = "c1fe7dda2d3233ac820a6c55a3bb67a5b2bd202e"; | |
| sha256 = "sha256:0lnlgx762ck9kjkv0f08vf6gmbv5bxxmzfvf0ky2v1msydp4wxhg"; | |
| }; | |
| ql2nix-src = lib.cleanSource /home/luke/git/ql2nix; | |
| libs = lib.makeLibraryPath (with xlibs; [ | |
| libGL pulseaudio libXxf86vm libX11 libxcb libXinerama openssl | |
| libXcursor libXrandr | |
| ]); | |
| build = writeScript "build.lisp" '' | |
| ;; Load SBCL policies | |
| (load "${./sbclrc.lisp}") | |
| ;; Setup quicklisp | |
| (load "quicklisp.lisp") | |
| (quicklisp-quickstart:install) | |
| ;; Load ql2nix from source | |
| (load "${ql2nix-src}/main.lisp") | |
| ;(ql-dist:install-dist "http://bodge.borodust.org/dist/org.borodust.bodge.txt" :replace t :prompt nil) | |
| ;; Generate dependency definitions | |
| (ql2nix:main (list "--nixlisp-lib" ${lib.concatMapStringsSep " " (x: "\""+x+"\"") quicklisp-packages})) | |
| (quit) | |
| ''; | |
| generate = writeScriptBin "generate" '' | |
| set -e | |
| # Remember output directory | |
| out=$(pwd)/../nix/lisp/nixlisp | |
| # Create temporary home directory to work in | |
| tmp=$(mktemp -d --suffix=.boot.ql2nix) | |
| trap "rm -rf $tmp" EXIT | |
| cd $tmp | |
| HOME=$(pwd) | |
| export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${libs} | |
| # Install Quicklisp and run ql2nix | |
| curl -O https://beta.quicklisp.org/quicklisp.lisp | |
| bash -x $(which common-lisp.sh) --load ${build} | |
| # Copy generated files into output directory | |
| echo "Copying generated files" | |
| cp --no-preserve=mode --remove-destination -v -f qlDist.nix ${ql2nix-src}/{mkNixlispBundle,nixlispDist,nixlispBundle}.nix $out/ | |
| ''; | |
| in | |
| # Derivation defining an environment for use with nix-shell. | |
| runCommand "env" | |
| { | |
| buildInputs = with xlibs; [ | |
| curl nix sbcl lispPackages.clwrapper z3 cvc4 openblas | |
| generate | |
| ]; | |
| } | |
| "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment