1{
2 stdenv,
3 lib,
4 fetchFrom9Front,
5 unstableGitUpdater,
6 installShellFiles,
7 makeWrapper,
8 apple-sdk_13,
9 xorg,
10 pkg-config,
11 wayland-scanner,
12 pipewire,
13 wayland,
14 wayland-protocols,
15 libxkbcommon,
16 libdecor,
17 pulseaudio,
18 nixosTests,
19 withWayland ? false,
20}:
21let
22 withXorg = !(withWayland || stdenv.hostPlatform.isDarwin);
23in
24stdenv.mkDerivation {
25 pname = "drawterm";
26 version = "0-unstable-2025-06-29";
27
28 src = fetchFrom9Front {
29 owner = "plan9front";
30 repo = "drawterm";
31 rev = "903bcd8dba9cb9dfc70707a28089c469e5302539";
32 hash = "sha256-gZAPNRzAuvpIAV7ArPGsqVv6SYBJkqA+Okf6FmStvsU=";
33 };
34
35 enableParallelBuilding = true;
36 strictDeps = true;
37 nativeBuildInputs = [
38 installShellFiles
39 makeWrapper
40 ]
41 ++ lib.optionals withWayland [
42 pkg-config
43 wayland-scanner
44 ];
45
46 buildInputs =
47 lib.optionals withWayland [
48 pipewire
49 wayland
50 wayland-protocols
51 libxkbcommon
52 libdecor
53 ]
54 ++ lib.optionals withXorg [
55 xorg.libX11
56 xorg.libXt
57 ]
58 ++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk_13;
59
60 makeFlags =
61 lib.optional withWayland "CONF=linux"
62 ++ lib.optional (!(withWayland || stdenv.hostPlatform.isDarwin)) "CONF=unix"
63 ++ lib.optionals stdenv.hostPlatform.isDarwin [
64 "CONF=osx-cocoa"
65 "CC=clang"
66 ];
67
68 installPhase = ''
69 installManPage drawterm.1
70 ''
71 + lib.optionalString withWayland ''
72 install -Dm755 -t $out/bin/ drawterm
73 ''
74 + lib.optionalString (!(withWayland || stdenv.hostPlatform.isDarwin)) ''
75 # wrapping the oss output with pulse seems to be the easiest
76 mv drawterm drawterm.bin
77 install -Dm755 -t $out/bin/ drawterm.bin
78 makeWrapper ${pulseaudio}/bin/padsp $out/bin/drawterm --add-flags $out/bin/drawterm.bin
79 ''
80 + lib.optionalString stdenv.hostPlatform.isDarwin ''
81 mkdir -p $out/{Applications,bin}
82 mv gui-cocoa/drawterm.app $out/Applications/
83 mv drawterm $out/Applications/drawterm.app/
84 ln -s $out/Applications/drawterm.app/drawterm $out/bin/
85 '';
86
87 passthru = {
88 updateScript = unstableGitUpdater { shallowClone = false; };
89 tests = nixosTests.drawterm;
90 };
91
92 meta = {
93 description = "Connect to Plan 9 CPU servers from other operating systems";
94 homepage = "https://drawterm.9front.org/";
95 license = lib.licenses.mit;
96 maintainers = with lib.maintainers; [ moody ];
97 platforms = with lib.platforms; linux ++ darwin;
98 mainProgram = "drawterm";
99 };
100}