nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 buildGoModule,
3 fetchFromGitHub,
4 makeWrapper,
5 pkg-config,
6 libpulseaudio,
7 dotool,
8 libGL,
9 libxxf86vm,
10 libxrandr,
11 libxi,
12 libxinerama,
13 libxcursor,
14 libx11,
15 libxkbcommon,
16 wayland,
17 lib,
18 stdenv,
19 nix-update-script,
20 testers,
21}:
22
23buildGoModule (finalAttrs: {
24 pname = "voxinput";
25 version = "0.9.0";
26
27 src = fetchFromGitHub {
28 owner = "richiejp";
29 repo = "VoxInput";
30 tag = "v${finalAttrs.version}";
31 hash = "sha256-0fdzL8J84XNpriuIUfMUzYpopyDqNMwCYAlzw68pMN4=";
32 };
33
34 vendorHash = "sha256-Ngb5fXHeQLDhCFHICH7Uj57GOQcMPxF2eIJaDIhl7S0=";
35
36 nativeBuildInputs = [
37 makeWrapper
38 pkg-config
39 ];
40
41 buildInputs = [
42 libpulseaudio
43 dotool
44
45 libGL
46 libx11.dev
47 libxcursor
48 libxi
49 libxinerama
50 libxrandr
51 libxxf86vm
52 libxkbcommon
53 wayland
54 ];
55
56 # To take advantage of the udev rule something like `services.udev.packages = [ nixpkgs.voxinput ]`
57 # needs to be added to your configuration.nix
58 postInstall = ''
59 mv $out/bin/VoxInput $out/bin/voxinput_tmp ; mv $out/bin/voxinput_tmp $out/bin/voxinput
60 ''
61 + lib.optionalString stdenv.hostPlatform.isLinux ''
62 wrapProgram $out/bin/voxinput \
63 --prefix PATH : ${lib.makeBinPath [ dotool ]}
64 mkdir -p $out/lib/udev/rules.d
65 echo 'KERNEL=="uinput", GROUP="input", MODE="0620", OPTIONS+="static_node=uinput"' > $out/lib/udev/rules.d/99-voxinput.rules
66 '';
67
68 postFixup = lib.optionalString stdenv.hostPlatform.isElf ''
69 patchelf $out/bin/.voxinput-wrapped \
70 --add-rpath ${lib.makeLibraryPath [ libpulseaudio ]}
71 '';
72
73 passthru = {
74 updateScript = nix-update-script { };
75 tests.version = testers.testVersion {
76 package = finalAttrs.finalPackage;
77 command = "voxinput ver";
78 version = "v${finalAttrs.version}";
79 };
80 };
81
82 meta = {
83 homepage = "https://github.com/richiejp/VoxInput";
84 description = "Voice to text for any Linux app via dotool/uinput and the LocalAI/OpenAI transcription API";
85 license = lib.licenses.mit;
86 maintainers = [ lib.maintainers.richiejp ];
87 platforms = lib.platforms.unix;
88 changelog = "https://github.com/richiejp/VoxInput/releases/tag/v${finalAttrs.version}";
89 mainProgram = "voxinput";
90 };
91})