Created
July 23, 2020 15:00
-
-
Save lukego/aa8b1ae1d2c6c98667c72cacbbbcee9c to your computer and use it in GitHub Desktop.
This file contains 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 = [ | |
"alexandria" | |
"bordeaux-threads" | |
"cffi" | |
"check-it" | |
"cl-csv" | |
"cl-digraph" | |
"cl-geometry" | |
"cl-interpol" | |
"cl-json" | |
"cl-pdf" | |
"cl-ppcre" | |
"cl-svg" | |
"cl-who" | |
"esrap" | |
# Selection of data structures | |
"heap" "cl-heap" "minheap" "binomial-heap" | |
"split-sequence" | |
"serapeum" | |
"vecto" | |
"flexi-streams" | |
"physical-quantities" | |
"named-readtables" | |
"parachute" | |
"trivial-shell" | |
"uiop" | |
# "quicklisp" | |
]; in | |
{ | |
pkgs ? import <nixpkgs> {}, | |
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 | |
libXcursor libXrandr | |
]); | |
build = writeScript "build.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 | |
generate | |
]; | |
} | |
"" |
This file contains 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
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; | |
with stdenv; | |
let | |
mkNixlispBundle = import ./nixlisp/mkNixlispBundle.nix pkgs; | |
nixlispBundle = mkNixlispBundle (import ./nixlisp/qlDist.nix); | |
myEmacsConfig = writeText "default.el" '' | |
(require 'package) | |
(package-initialize 'noactivate) | |
(eval-when-compile | |
(require 'use-package)) | |
(use-package magit) | |
;(use-package forge) | |
(use-package paredit) | |
(use-package counsel) | |
(use-package counsel-projectile) | |
(use-package flycheck) | |
(use-package company) | |
(use-package nix-mode) | |
(use-package redshank) | |
;(use-package org-preview-html) | |
(use-package ivy | |
:config (ivy-mode 1)) | |
(use-package slime | |
:config | |
(setq slime-contribs '(slime-fancy slime-indentation) | |
inferior-lisp-program "nuddy-lisp")) | |
(use-package org | |
:init | |
(setq org-babel-load-languages | |
'((awk . t) (calc . t) (C . t) (gnuplot . t) (emacs-lisp . t) | |
(gnuplot . t) (R . t) | |
(lisp . t))) | |
:config | |
(setq org-confirm-babel-evaluate nil)) | |
''; | |
myEmacs = emacsWithPackages (epkgs: (with epkgs.melpaPackages; [ | |
(runCommand "default.el" {} '' | |
mkdir -p $out/share/emacs/site-lisp | |
cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el | |
'') | |
magit | |
forge | |
paredit | |
redshank | |
slime | |
ivy | |
flycheck | |
counsel | |
counsel-projectile | |
company | |
nix-mode | |
use-package | |
ob-diagrams | |
ob-tmux | |
ob-http | |
])); | |
in | |
pkgs.stdenv.mkDerivation rec { | |
name = "example"; | |
buildInputs = with xlibs; [ sbcl lispPackages.clwrapper nixlispBundle myEmacs git | |
libXrandr libXinerama libXxf86vm | |
libxcb libXcursor libGL glfw | |
]; | |
# ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment