Skip to content

Commit 6007ac5

Browse files
committed
tabby wip
1 parent 189d4e3 commit 6007ac5

File tree

3 files changed

+143
-60
lines changed

3 files changed

+143
-60
lines changed

nix/configuration.nix

Lines changed: 98 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -91,80 +91,85 @@
9191
exe,
9292
dir,
9393
net ? false,
94+
cfg ? "",
9495
}: {
9596
"${pkg}" = {
9697
executable = exe;
97-
profile = mkFirejailProfile {inherit pkg dir net;};
98+
profile = mkFirejailProfile {inherit pkg dir net cfg;};
9899
};
99100
};
100101
mkFirejailProfile = {
101102
pkg,
102103
dir,
103-
net ? false,
104+
net,
105+
cfg,
104106
}:
105-
pkgs.writeText "${pkg}.local" ''
106-
include default.profile
107+
pkgs.writeText "${pkg}.local" (
108+
''
109+
include default.profile
107110
108-
include disable-X11.inc
109-
include disable-common.inc
110-
include disable-devel.inc
111-
include disable-exec.inc
112-
include disable-interpreters.inc
113-
include disable-proc.inc
114-
include disable-programs.inc
115-
include disable-shell.inc
116-
include disable-write-mnt.inc
117-
include disable-xdg.inc
111+
include disable-X11.inc
112+
include disable-common.inc
113+
include disable-devel.inc
114+
include disable-exec.inc
115+
include disable-interpreters.inc
116+
include disable-proc.inc
117+
include disable-programs.inc
118+
include disable-shell.inc
119+
include disable-write-mnt.inc
120+
include disable-xdg.inc
118121
119-
# no3d
120-
# nosound
121-
apparmor
122-
caps.drop all
123-
machine-id
124-
${
125-
if net
126-
then ""
127-
else "net none"
128-
}
129-
netfilter
130-
nodvd
131-
nogroups
132-
noinput
133-
nonewprivs
134-
noprinters
135-
noroot
136-
notv
137-
nou2f
138-
novideo
139-
shell none
122+
# no3d
123+
# nosound
124+
apparmor
125+
caps.drop all
126+
machine-id
127+
${
128+
if net
129+
then ""
130+
else "net none"
131+
}
132+
netfilter
133+
nodvd
134+
nogroups
135+
noinput
136+
nonewprivs
137+
noprinters
138+
noroot
139+
notv
140+
nou2f
141+
novideo
142+
shell none
140143
141-
disable-mnt
142-
private ''${HOME}/.firejail/${dir}
143-
private-bin none
144-
private-cache
145-
private-cwd
146-
private-dev
147-
${
148-
if net
149-
then ""
150-
else "private-etc none"
151-
}
152-
private-lib none
153-
private-opt none
154-
private-srv none
155-
private-tmp
156-
seccomp
157-
${
158-
if net
159-
then ""
160-
else "x11 none"
161-
}
144+
disable-mnt
145+
private ''${HOME}/.firejail/${dir}
146+
private-bin none
147+
private-cache
148+
private-cwd
149+
private-dev
150+
${
151+
if net
152+
then ""
153+
else "private-etc none"
154+
}
155+
private-lib none
156+
private-opt none
157+
private-srv none
158+
private-tmp
159+
seccomp
160+
${
161+
if net
162+
then ""
163+
else "x11 none"
164+
}
162165
163-
dbus-system none
164-
dbus-user none
166+
dbus-system none
167+
dbus-user none
165168
166-
restrict-namespaces
167-
'';
169+
restrict-namespaces
170+
''
171+
+ cfg
172+
);
168173
mkFirejailWrapper = {
169174
pkgs,
170175
pkg,
@@ -806,6 +811,8 @@ in {
806811
"networkmanager"
807812
"scanner"
808813
"ydotool"
814+
"render"
815+
"video"
809816
"lp"
810817
];
811818
#
@@ -899,6 +906,37 @@ in {
899906
-file ./ashes/Ashes2063EnrichedFDPatch.pk3 \
900907
-file ./SimpleSlots.1.1.pk7
901908
'';
909+
}
910+
// mkFirejailCustom {
911+
pkg = "tabby-download-embed";
912+
dir = "tabby";
913+
net = true;
914+
exe = ''
915+
${import ./tabby.nix}/bin/tabby \
916+
download --model Nomic-Embed-Text
917+
'';
918+
}
919+
// mkFirejailCustom {
920+
pkg = "tabby-download-qwen";
921+
dir = "tabby";
922+
net = true;
923+
exe = ''
924+
${import ./tabby.nix}/bin/tabby \
925+
download --model Qwen2.5-Coder-0.5B
926+
'';
927+
}
928+
// mkFirejailCustom {
929+
pkg = "tabby-serve-qwen";
930+
dir = "tabby";
931+
cfg = ''
932+
env SWC_DEBUG=1
933+
env RUST_LOG=trace
934+
env TABBY_DISABLE_USAGE_COLLECTION=1
935+
'';
936+
exe = ''
937+
${import ./tabby-socat.nix}/bin/tabby-socat \
938+
serve --model Qwen2.5-Coder-0.5B
939+
'';
902940
};
903941

904942
#

nix/tabby-socat.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let
2+
pkgs = import ./nixpkgs.nix;
3+
in
4+
pkgs.writeShellApplication {
5+
name = "tabby-socat";
6+
text = ''
7+
${pkgs.socat}/bin/socat \
8+
UNIX-LISTEN:./tabby.sock,fork,reuseaddr,keepalive \
9+
TCP:localhost:8080,keepalive &
10+
${import ./tabby.nix}/bin/tabby "$@" &
11+
wait -n
12+
exit $?
13+
'';
14+
}

nix/tabby.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
let
2+
pkgs = import ./nixpkgs.nix;
3+
pname = "tabby-vulkan";
4+
version = "0.25.1";
5+
src = builtins.fetchurl {
6+
url = "https://github.com/TabbyML/tabby/releases/download/v${version}/tabby_x86_64-manylinux_2_28-vulkan.tar.gz";
7+
sha256 = "1hfddjpa9q42giya5zxqw9db0vhg0pqgd4hy4yfipcw8diz169i7";
8+
};
9+
in
10+
pkgs.stdenv.mkDerivation {
11+
inherit src pname version;
12+
buildInputs = [
13+
# tabby
14+
pkgs.libz
15+
pkgs.libgcc
16+
# llama-server
17+
pkgs.vulkan-loader # libvulkan
18+
(pkgs.lib.getLib pkgs.stdenv.cc.cc) # libgomp libstdc++
19+
];
20+
nativeBuildInputs = [
21+
pkgs.autoPatchelfHook
22+
];
23+
installPhase = ''
24+
mkdir -p $out/bin
25+
cp tabby $out/bin
26+
cp llama-server $out/bin
27+
'';
28+
fixupPhase = ''
29+
autoPatchelf $out/bin
30+
'';
31+
}

0 commit comments

Comments
 (0)