nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 unzip,
6 flex,
7 tk,
8 ncurses,
9 readline,
10}:
11
12stdenv.mkDerivation {
13 pname = "lc3tools";
14 version = "0.12";
15
16 src = fetchurl {
17 url = "https://highered.mheducation.com/sites/dl/free/0072467509/104652/lc3tools_v12.zip";
18 hash = "sha256-PTM0ole8pHiJmUaahjPwcBQY8/hVVgQhADZ4bSABt3I=";
19 };
20
21 patches = [
22 # the original configure looks for things in the FHS path
23 # I have modified it to take environment vars
24 ./0001-mangle-configure.patch
25
26 # lc3sim looks for the LC3 OS in $out/share/lc3tools instead of $out
27 ./0002-lc3os-path.patch
28
29 # lc3sim-tk looks for lc3sim in $out/bin instead of $out
30 ./0003-lc3sim-tk-path.patch
31
32 # use `cc` instead of `gcc`; on macOS the latter is not present
33 ./0004-configure-use-cc.patch
34 ];
35
36 nativeBuildInputs = [ unzip ];
37 buildInputs = [
38 flex
39 tk
40 ncurses
41 readline
42 ];
43
44 # lumetta published this a while ago but handrolled his configure
45 # jank in the original packaging makes this necessary:
46 LIBS = "${flex}/lib:${ncurses}/lib:${readline}/lib";
47 INCLUDES = "${flex}/include:${ncurses}/include:${readline}/include";
48
49 # it doesn't take `--prefix`
50 prefixKey = "--installdir ";
51
52 postInstall = ''
53 mkdir -p $out/{bin,share/lc3tools}
54
55 mv -t $out/share/lc3tools $out/{COPYING,NO_WARRANTY,README} $out/lc3os*
56 mv -t $out/bin $out/lc3*
57 '';
58
59 meta = with lib; {
60 longDescription = ''
61 The LC-3 tools package contains the lc3as assembler, the lc3sim simulator,
62 and lc3sim-tk, a Tcl/Tk-based GUI frontend to the simulator.
63 '';
64 description = "Toolchain and emulator for the LC-3 architecture";
65 homepage = "https://highered.mheducation.com/sites/0072467509/student_view0/lc-3_simulator.html";
66 license = licenses.gpl2;
67 maintainers = with maintainers; [ anna328p ];
68 mainProgram = "lc3sim-tk";
69 platforms = with lib.platforms; unix ++ windows;
70 };
71}