-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
260 lines (230 loc) · 7.42 KB
/
default.nix
File metadata and controls
260 lines (230 loc) · 7.42 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
{ lib, newScope, stdenv, fetchgit, pkgs }: let
# nicer aliases
derive = stdenv.mkDerivation;
concat = builtins.concatStringsSep " ";
# vendored libuvc: don't build, just make sources available
libuvc-src = derive {
name = "libuvc-src";
# using fetchgit instead fetchFromGitHub because
# the .git directory is needed by arcan's cmake scripts
src = fetchgit {
leaveDotGit = true;
url = "https://github.com/letoram/libuvc.git";
rev = "v0.0.6";
sha256 = "1jdmiinsd91nnli5hgcn9c6ifj0s6ngbyjwm0z6fim4f8krnh0sf";
};
nativeBuildInputs = with pkgs; [ git ];
# fetchgit strips all refs, leaving just a fetchgit branch
# but cmake needs to check out the ref called 'master':
installPhase = ''
git tag master
cp -r . $out/
cd $out
'';
};
# cmake flags pointing to locations of arcan headers
arcanIncludeDirs = arcan: [
"-DARCAN_SHMIF_INCLUDE_DIR=${arcan}/include/arcan/shmif"
"-DARCAN_TUI_INCLUDE_DIR=${arcan}/include/arcan"
];
# cmake flags pointing to locations of libusb1 headers and binaries
libusbDirs = libusb1: [
"-DLIBUSB_1_INCLUDE_DIRS=${libusb1.dev}/include/libusb-1.0"
"-DLIBUSB_1_LIBRARIES=${libusb1}/lib/libusb-1.0.so"
];
in lib.makeScope newScope (self: with self; let
arcanRev = "0.6.0.1";
arcanCoreSrc = fetchgit {
leaveDotGit = true;
url = "https://github.com/letoram/arcan.git";
rev = arcanRev;
sha256 = "1hfqj39klbnh47lv1lbfs4l12kl58l5xkmdmzdc5fi4yg8h56njs";
};
in {
# arcan core:
arcan = callPackage ({ pkgs }: derive {
name = "arcan";
src = arcanCoreSrc;
#patches = [ ./Arcan.nosuid.patch ]; # nix refuses to build suid binaries
postUnpack = '' # add vendored libuvc
mkdir -p ./arcan/external/git/libuvc
pushd ./arcan/external/git/
shopt -s dotglob nullglob # bashism: * now also matches dotfiles
cp -r ${libuvc-src}/* libuvc/
shopt -u dotglob nullglob # phases are stateful
popd
'';
patchPhase = '' # thanks @ChrisOboe!
sed -i "s,SETUID,,g" ./src/CMakeLists.txt
substituteInPlace ./src/platform/posix/paths.c \
--replace "/usr/bin" "$out/bin" \
--replace "/usr/share" "$out/share"
'';
nativeBuildInputs = with pkgs; [ cmake gcc git pkg-config ];
buildInputs = with pkgs; [
apr
espeak-classic
file
ffmpeg-full
freetype
harfbuzzFull
leptonica
libGL
libdrm
libjpeg
libusb1
libvncserver
libxkbcommon
luajit
lzma
mesa
openal
SDL2
sqlite
tesseract
vlc
wayland
wayland-protocols
xorg.libxcb
xorg.xcbutil
xorg.xcbutilwm
];
PKG_CONFIG_PATH = concat [ # make wayland protocols available
"${pkgs.wayland-protocols}/share/pkgconfig"
"${pkgs.libusb1.dev}/lib/pkgconfig"
];
CFLAGS = concat [ # don't warn on read()/write() without a format
"-Wno-format" # (Arcan code uses them on SHMIFs)
"-Wno-format-security"
];
cmakeFlags = concat (
# cmake won't be able to find these paths on its own:
(libusbDirs pkgs.libusb) ++ [
"-DDRM_INCLUDE_DIR=${pkgs.libdrm.dev}/include/libdrm"
"-DGBM_INCLUDE_DIR=${pkgs.libGL.dev}/include"
"-DWAYLANDPROTOCOLS_PATH=${pkgs.wayland-protocols}/share/wayland-protocols"
# enable features:
"-DVIDEO_PLATFORM=egl-dri"
"-DSHMIF_TUI_ACCEL=ON"
"-DENABLE_LWA=ON"
"-DNO_BUILTIN_OPENHMD=ON"
"-DHYBRID_SDL=On"
"-DHYBRID_HEADLESS=On"
"-DFSRV_DECODE_UVC=Off"
# optional
"-DVERBOSE=ON"
#"--debug-output"
#"--trace"
"../src"
]);
}) {};
# arcan utilities:
acfgfs = callPackage ({ pkgs }: derive {
name = "acfgfs";
src = arcanCoreSrc;
nativeBuildInputs = with pkgs; [ cmake gcc git pkg-config ];
buildInputs = [ arcan ] ++ (with pkgs; [ fuse3 ]);
cmakeFlags = concat ((arcanIncludeDirs arcan) ++ [ "../src/tools/acfgfs" ]);
}) {};
aclip = callPackage ({ pkgs }: derive {
name = "aclip";
src = arcanCoreSrc;
nativeBuildInputs = with pkgs; [ cmake gcc git pkg-config ];
buildInputs = [ arcan ];
PKG_CONFIG_PATH = concat [ "${arcan}/lib/pkgconfig" ];
cmakeFlags = concat ((arcanIncludeDirs arcan) ++ [ "../src/tools/aclip" ]);
}) {};
aloadimage = callPackage ({ pkgs }: derive {
name = "aloadimage";
src = arcanCoreSrc;
nativeBuildInputs = with pkgs; [ cmake gcc git pkg-config ];
buildInputs = [ arcan ];
cmakeFlags = concat ((arcanIncludeDirs arcan) ++ [ "../src/tools/aloadimage" ]);
}) {};
shmmon = callPackage ({ pkgs }: derive {
name = "shmmon";
src = arcanCoreSrc;
nativeBuildInputs = with pkgs; [ cmake gcc git pkg-config ];
buildInputs = [ arcan ];
cmakeFlags = concat ((arcanIncludeDirs arcan) ++ [ "../src/tools/shmmon" ]);
}) {};
# TODO: provide <hidapi/hidapi.h> include path
#vrbridge = callPackage ({ pkgs }: derive {
#name = "vrbridge";
#src = ./arcan;
#nativeBuildInputs = with pkgs; [ cmake gcc git pkg-config ];
#buildInputs = [ arcan ] ++ (with pkgs; [ libusb1 ]);
#cmakeFlags = concat (
#(arcanIncludeDirs arcan) ++
#(libusbDirs pkgs.libusb1) ++
#[ "../src/tools/vrbridge" ]
#);
#}) {};
} // (let
mkArcanAppl = { name, src, applRoot }: callPackage (
{ bash
, pkg-config
}: derive {
name = name;
src = src;
nativeBuildInputs = [ pkg-config ];
buildInputs = [ arcan ];
installPhase = ''
mkdir -p $out/bin $out/share/${name} $out/share/wayland-sessions
# add appl code
cp -r ./${applRoot}/* $out/share/${name}/
# create executable wrapper
echo -e "#!${bash}/bin/bash\nexec /run/wrappers/bin/arcan $out/share/${name}" \
> $out/bin/${name}
chmod +x $out/bin/${name}
# create session wrapper
echo -e "[Desktop Entry]\nName=${name} on Arcan ${arcanRev}\nComment=Next Generation Window Manager\nExec=$out/bin/durden\nType=Application" \
> $out/share/wayland-sessions/${name}.desktop
chmod +x $out/share/wayland-sessions/${name}.desktop
'';
passthru.providedSessions = [ name ];
}
) {};
in {
# arcan appls
awb = mkArcanAppl {
name = "awb";
src = fetchgit {
leaveDotGit = true;
url = "https://github.com/letoram/awb.git";
rev = "271ef7ffd7f24569d2f836198e4c96b8c617e372";
sha256 = "0g6g493ygabhwfknjlp2rg14iq7njsgh5qll01p2g1i9qvwbbhvq";
};
applRoot = "";
};
prio = mkArcanAppl {
name = "prio";
src = fetchgit {
leaveDotGit = true;
url = "https://github.com/letoram/prio.git";
rev = "c3f97491339d15f063d6937d5f89bcfaea774dd1";
sha256 = "0igsbzp0df24f856sfwzcgcfanxlvxmw5v94gqq2p42kwardfmm9";
};
applRoot = "";
};
durden = mkArcanAppl {
name = "durden";
src = fetchgit {
leaveDotGit = true;
url = "https://github.com/letoram/durden.git";
rev = "bfbfe68bc325a5fb06ea1869a99404e277291a89";
sha256 = "0d5g161xaccq3jxci9vwr2xn51ilrcdh3a9sdlsw3d64a1f4x4rv";
};
applRoot = "durden";
};
/*safespaces = mkArcanAppl {
name = "safespaces";
src = fetchgit {
leaveDotGit = true;
url = "https://github.com/letoram/safespaces.git";
rev = "https://github.com/letoram/safespaces/commit/58eef59afba091293cab4d2b156e725f75d92eaf";
sha256 = "1jdmiinsd91nnli5hgcn9c6ifj0s6ngbyjwm0z6fim4f8krnh0s9";
};
applRoot = "safespaces";
};*/
}))