Skip to content

Commit ba01c34

Browse files
committed
chore: Add version switch and Nix flake build
Signed-off-by: Richard Palethorpe <io@richiejp.com>
1 parent 1d21d39 commit ba01c34

4 files changed

Lines changed: 58 additions & 6 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
VoxInput
1+
VoxInput
2+
voxinput
3+
result

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ KERNEL=="uinput", GROUP="input", MODE="0620", OPTIONS+="static_node=uinput"
6262
5. It makes sense to bind the `record` and `write` commands to keys using your window manager. For instance in my Sway config I have the following
6363

6464
```
65-
bindsym $mod+Shift+t exec VoxInput record
66-
bindsym $mod+t exec VoxInput write
65+
bindsym $mod+Shift+t exec voxinput record
66+
bindsym $mod+t exec voxinput write
6767
```
6868

69+
Alternatively you can use the Nix flake.
70+
6971
## Usage
7072

7173
### Commands
@@ -111,7 +113,7 @@ bindsym $mod+t exec VoxInput write
111113

112114
## TODO
113115

114-
- [ ] Put playback behind a debug switch
116+
- [x] Put playback behind a debug switch
115117
- [ ] Create a release
116118
- [ ] Realtime Transcription
117119
- [ ] GUI and system tray

flake.nix

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
outputs = { self, nixpkgs }:
77
let
8-
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
8+
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
99
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
1010
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
1111
in
@@ -28,5 +28,44 @@
2828
LD_LIBRARY_PATH = "${pkgs.libpulseaudio}/lib";
2929
};
3030
});
31+
32+
packages = forAllSystems (system:
33+
let
34+
pkgs = nixpkgsFor.${system};
35+
in
36+
{
37+
default = pkgs.buildGoModule {
38+
pname = "voxinput";
39+
version = "0.1.0";
40+
41+
# Path to the source code
42+
src = ./.;
43+
44+
vendorHash = "sha256-OserWlRhKyTvLrYSikNCjdDdTATIcWTfqJi9n4mHVLE="; #nixpkgs.lib.fakeHash;
45+
46+
# Include runtime dependencies
47+
buildInputs = with pkgs; [
48+
libpulseaudio
49+
dotool
50+
];
51+
52+
# Ensure libpulseaudio is available at runtime
53+
LD_LIBRARY_PATH = "${pkgs.libpulseaudio}/lib";
54+
55+
# To take advantage of this something like services.udev.packages = [ nixpkgs.voxinput ] is required
56+
postInstall = ''
57+
mv $out/bin/VoxInput $out/bin/voxinput
58+
mkdir -p $out/lib/udev/rules.d
59+
echo 'KERNEL=="uinput", GROUP="input", MODE="0620", OPTIONS+="static_node=uinput"' > $out/lib/udev/rules.d/99-voxinput.rules
60+
'';
61+
62+
meta = with pkgs.lib; {
63+
description = "Transcribe input from your microphone and turn it into key presses on a virtual keyboard.";
64+
license = licenses.mit;
65+
maintainers = [ maintainers.richiejp ];
66+
platforms = platforms.unix;
67+
};
68+
};
69+
});
3170
};
3271
}

main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import (
1010
"github.com/richiejp/VoxInput/internal/pid"
1111
)
1212

13+
// Sync with flake
14+
const version = "0.1.0"
15+
1316
func main() {
1417

1518
if len(os.Args) < 2 {
@@ -19,13 +22,19 @@ func main() {
1922

2023
cmd := os.Args[1]
2124

22-
if cmd == "help" {
25+
switch cmd {
26+
case "help":
2327
fmt.Println("Available commands:")
2428
fmt.Println(" listen - Start speech to text daemon (use --replay to play the audio just recorded for transcription)")
2529
fmt.Println(" record - Tell existing listener to start recording audio")
2630
fmt.Println(" write - Tell existing listener to stop recording audio and transcribe it")
2731
fmt.Println(" help - Show this help message")
32+
fmt.Println(" ver - Print version")
2833
return
34+
case "ver":
35+
fmt.Printf("v%s\n", version)
36+
return
37+
default:
2938
}
3039

3140
pidPath, err := pid.Path()

0 commit comments

Comments
 (0)