-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathflake.nix
More file actions
109 lines (96 loc) · 3.59 KB
/
flake.nix
File metadata and controls
109 lines (96 loc) · 3.59 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
{
description = "VoxInput";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
localvqe-src = {
url = "git+https://github.com/localai-org/LocalVQE?submodules=1";
flake = false;
};
};
outputs = { self, nixpkgs, localvqe-src }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
devShells = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell.override { stdenv = pkgs.clangStdenv; } {
buildInputs = with pkgs; [
go
gopls
gotools
go-tools
libpulseaudio
dotool
cmake
libGL pkg-config libx11.dev libxcursor libxi libxinerama libxrandr libxxf86vm libxkbcommon wayland
];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.libpulseaudio ];
};
});
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
lib = pkgs.lib;
stdenv = pkgs.stdenv;
localvqe-lib = pkgs.stdenv.mkDerivation {
pname = "liblocalvqe";
version = "0.1.0";
src = localvqe-src + "/ggml";
nativeBuildInputs = [ pkgs.cmake ];
cmakeFlags = [ "-DLOCALVQE_BUILD_SHARED=ON" "-DCMAKE_BUILD_TYPE=Release" ];
installPhase = ''
mkdir -p $out/lib $out/include
cp liblocalvqe.so* $out/lib/ || true
cp liblocalvqe.so $out/lib/ || true
cp ${localvqe-src + "/ggml/localvqe_api.h"} $out/include/
'';
};
in
{
default = pkgs.buildGoModule {
pname = "voxinput";
# sync with main.go
version = lib.strings.removeSuffix "\n" (builtins.readFile ./version.txt);
# Path to the source code
src = ./.;
vendorHash = "sha256-50ZSwdZS+yLYGevb2KuWE/0PxaDq44zYzwYztYNNJqw=";
nativeBuildInputs = with pkgs; [
makeWrapper
pkg-config
];
# Include runtime dependencies
buildInputs = with pkgs; [
libpulseaudio
dotool
localvqe-lib
libGL libx11.dev libxcursor libxi libxinerama libxrandr libxxf86vm libxkbcommon wayland
];
postInstall = ''
mv $out/bin/VoxInput $out/bin/voxinput_tmp ; mv $out/bin/voxinput_tmp $out/bin/voxinput
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
wrapProgram $out/bin/voxinput \
--prefix PATH : ${lib.makeBinPath [ pkgs.dotool ]}
mkdir -p $out/lib/udev/rules.d
echo 'KERNEL=="uinput", GROUP="input", MODE="0620", OPTIONS+="static_node=uinput"' > $out/lib/udev/rules.d/99-voxinput.rules
'';
postFixup = lib.optionalString stdenv.hostPlatform.isElf ''
patchelf $out/bin/.voxinput-wrapped \
--add-rpath ${lib.makeLibraryPath [ pkgs.libpulseaudio localvqe-lib ]}
'';
meta = with pkgs.lib; {
description = "Transcribe input from your microphone and turn it into key presses on a virtual keyboard.";
license = licenses.mit;
maintainers = [ maintainers.richiejp ];
platforms = platforms.unix;
};
};
});
};
}