@@ -0,0 +1,42 @@
1+{ stdenv, fetchurl, unzip, flex, tk, ncurses, readline }:
2+
3+stdenv.mkDerivation {
4+ pname = "lc3tools";
5+ version = "0.12";
6+
7+ src = fetchurl {
8+ url = "https://highered.mheducation.com/sites/dl/free/0072467509/104652/lc3tools_v12.zip";
9+ hash = "sha256-PTM0ole8pHiJmUaahjPwcBQY8/hVVgQhADZ4bSABt3I=";
10+ };
11+
12+ patches = [
13+ # the original configure looks for things in the FHS path
14+ # I have modified it to take environment vars
15+ ./0001-mangle-configure.patch
16+ ];
17+
18+ nativeBuildInputs = [ unzip ];
19+ buildInputs = [ flex tk ncurses readline ];
20+
21+ # lumetta published this a while ago but handrolled his configure
22+ # jank in the original packaging makes this necessary:
23+ LIBS = "${flex}/lib:${ncurses}/lib:${readline}/lib";
24+ INCLUDES = "${flex}/include:${ncurses}/include:${readline}/include";
25+
26+ # it doesn't take `--prefix`
27+ prefixKey = "--installdir ";
28+
29+ postInstall = ''
30+ rm $out/{COPYING,NO_WARRANTY,README}
31+ mkdir -p $out/{bin,share/lc3tools}
32+
33+ mv -t $out/share/lc3tools $out/lc3os*
34+ mv -t $out/bin $out/lc3*
35+ '';
36+
37+ meta = with stdenv.lib; {
38+ description = "Toolchain and emulator for the LC-3 architecture";
39+ license = licenses.gpl2;
40+ maintainers = with maintainers; [ anna328p ];
41+ };
42+}