This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
159 lines (136 loc) · 5.24 KB
/
flake.nix
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
{
description = "Caching GitLab issues and more locally, for blazingly fast search";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
name = "cache-cache";
pkgs = nixpkgs.legacyPackages.${system};
lisp = "${pkgs.sbcl}/bin/sbcl --script";
# This is a project not in quicklisp, and the version in nixpkgs is too old
jzon = pkgs.lispPackages_new.build-asdf-system {
src = pkgs.fetchgit {
url = "https://github.com/Zulu-Inuoe/jzon.git";
rev = "ba43faa1f2a07e83226d0e52b29cf6a816e3596d";
sha256 = "sha256-MWitSH1vgszhlW0EgfPX/7lZHxdXZYYqhwWqrpaUWFc=";
};
version = "1.0.0-2021109-ba43faa";
pname = "jzon";
inherit lisp;
lispLibs = with pkgs.lispPackages_new.sbclPackages; [closer-mop flexi-streams];
systems = [ "com.inuoe.jzon" ];
};
# This another of my projects, it's not on quicklisp
simpbin = pkgs.lispPackages_new.build-asdf-system {
pname = "simpbin";
version = "0.0.1";
src = pkgs.fetchgit {
url = "https://github.com/fstamour/simpbin.git";
rev = "6f9f1c196ca8f363b478bab0a8623f53b89e5586"; # Master as of 9th Nov. 2022
sha256 = "sha256-FLCUYbC/oMpCqQNGo5Bh3UZyxYx4/Jm8VtXKuqtC5uA=";
};
inherit lisp;
lispLibs = with pkgs.lispPackages_new.sbclPackages; [alexandria flexi-streams fast-io nibbles];
};
lispLibs = with pkgs.lispPackages_new.sbclPackages;
[
drakma
log4cl
hunchentoot
find-port
kebab
str
local-time
cl-cron
adopt
jzon
simpbin
];
meta = {
homepage = "https://github.com/fstamour/${name}";
description = "Caching gitlab issues and more locally, for bazingly fast search";
license = pkgs.lib.licenses.mit;
maintainers = [ pkgs.maintainers.mpsyco ];
};
asdf-system-attrs = {
pname = "${name}";
version = "0.0.1";
src = ./.;
inherit lisp;
inherit lispLibs;
inherit meta;
};
# A derivation for the lisp system
asdf-system = pkgs.lispPackages_new.build-asdf-system asdf-system-attrs;
# A derivation for an executable for the lisp system
application = pkgs.lispPackages_new.build-asdf-system asdf-system-attrs // {
# Load the system, specify a top-level function and dump the
# executable core.
buildScript = pkgs.writeText "build-${name}.lisp" ''
(require :asdf)
(asdf:load-system '#:${name})
(uiop/image:dump-image "${name}" :executable t)
'';
# To make runtime depedencies (like openssl) available.
nativeBuildInputs = [ pkgs.makeWrapper ];
# Wrap the executable, keep only the executable as output.
installPhase = ''
source $stdenv/setup
mkdir -p $out/bin
mv ${name} $out/bin
wrapProgram $out/bin/${name} \
--prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH
'';
};
# A version of sbcl with some systems for development.
sbclWithPackages = (pkgs.lispPackages_new.sbclWithPackages
(p: [
asdf-system
p.swank
p.slynk
]));
# A small script to launch sbcl with swank started and the system loaded.
# TODO we probably won't need this if we configure emacs to start sbcl
start-swank-listener = pkgs.writeScriptBin "swank"
''
${pkgs.rlwrap}/bin/rlwrap ${sbclWithPackages}/bin/sbcl --noinform \
--eval "(asdf:load-system '#:${name})" \
--eval "(asdf:load-system '#:swank)" \
--eval "(swank:create-server :dont-close t)"
'';
emacs-setup-slime = pkgs.writeTextFile {
name = "setup-slime.el";
text = ''
(let ((slime-directory "${pkgs.lispPackages_new.sbclPackages.swank}"))
(add-to-list 'load-path slime-directory)
(require 'slime-autoloads)
(setq slime-backend (expand-file-name "swank-loader.lisp" slime-directory))
(setq slime-path slime-directory)
(slime-setup '(slime-fancy)))
(setq slime-lisp-implementations
`((sbcl ("${sbclWithPackages}/bin/sbcl" "--no-sysinit" "--no-userinit"
"--eval" "(require 'asdf)"))))
'';
};
# Small script to load slime (swank's emacs client) using emacsclient
swank-emacsclient = pkgs.writeScriptBin "swank-emacsclient"
''
${pkgs.emacs}/bin/emacsclient -n --eval "(load \"${emacs-setup-slime}\")"
'';
in {
packages.default = application;
devShells.default = pkgs.mkShell {
buildInputs = [
sbclWithPackages
pkgs.rlwrap
application
start-swank-listener
swank-emacsclient
];
};
}
);
}