From 6fae26733d099ca13315fd93105eeffda5dc7233 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 11 Mar 2026 17:40:21 -0400 Subject: [PATCH] feat: whisper --- config/nvim/lua/plugins/dev.lua | 6 +++- flake.lock | 55 +++++++++++++++++++++++++++++++++ flake.nix | 9 ++++-- home/home.nix | 1 + home/modules/dictation.nix | 51 ++++++++++++++++++++++++++++++ hosts/xps15/configuration.nix | 14 +++++++++ 6 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 home/modules/dictation.nix diff --git a/config/nvim/lua/plugins/dev.lua b/config/nvim/lua/plugins/dev.lua index d4d1841..487b8be 100644 --- a/config/nvim/lua/plugins/dev.lua +++ b/config/nvim/lua/plugins/dev.lua @@ -367,7 +367,11 @@ return { }) vim.g.preview = { debug = false, - github = true, + github = { + output = function(ctx) + return '/tmp/' .. vim.fn.fnamemodify(ctx.file, ':t:r') .. '.html' + end, + }, typst = { open = { 'sioyek', '--new-instance' } }, plantuml = true, mermaid = true, diff --git a/flake.lock b/flake.lock index e56aba1..5d38df8 100644 --- a/flake.lock +++ b/flake.lock @@ -39,6 +39,24 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -202,9 +220,46 @@ "neovim-nightly": "neovim-nightly", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs_3", + "whisper-dictation": "whisper-dictation", "zen-browser": "zen-browser" } }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "whisper-dictation": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1771198514, + "narHash": "sha256-5Dd0zVTh+nUf3lxrDpgQSHbr0pU40hGh/hUuRbwG790=", + "owner": "jacopone", + "repo": "whisper-dictation", + "rev": "20190a148d8bce6f0d0b78a56cc22afe02844e8f", + "type": "github" + }, + "original": { + "owner": "jacopone", + "repo": "whisper-dictation", + "type": "github" + } + }, "zen-browser": { "inputs": { "home-manager": "home-manager_2", diff --git a/flake.nix b/flake.nix index 72312ec..7a3ee18 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,10 @@ zen-browser.url = "github:0xc000022070/zen-browser-flake"; claude-code.url = "github:ryoppippi/claude-code-overlay"; neovim-nightly.url = "github:nix-community/neovim-nightly-overlay"; + whisper-dictation = { + url = "github:jacopone/whisper-dictation"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -21,6 +25,7 @@ zen-browser, claude-code, neovim-nightly, + whisper-dictation, ... }: let @@ -87,7 +92,7 @@ home-manager.lib.homeManagerConfiguration { pkgs = mkPkgs hostConfig.platform [ ]; extraSpecialArgs = { - inherit zen-browser hostConfig; + inherit zen-browser whisper-dictation hostConfig; }; modules = [ ./home/home.nix ]; }; @@ -139,7 +144,7 @@ home-manager.backupFileExtension = "bak"; home-manager.users.barrett = import ./home/home.nix; home-manager.extraSpecialArgs = { - inherit zen-browser; + inherit zen-browser whisper-dictation; hostConfig = xps15Config; }; } diff --git a/home/home.nix b/home/home.nix index 1928b8c..d6ad5be 100644 --- a/home/home.nix +++ b/home/home.nix @@ -19,6 +19,7 @@ ++ lib.optionals hostConfig.isLinux [ ./modules/hyprland.nix ./modules/ui.nix + ./modules/dictation.nix ]; config = { diff --git a/home/modules/dictation.nix b/home/modules/dictation.nix new file mode 100644 index 0000000..5060c3f --- /dev/null +++ b/home/modules/dictation.nix @@ -0,0 +1,51 @@ +{ + lib, + pkgs, + config, + hostConfig, + whisper-dictation, + ... +}: + +let + modelDir = "${config.home.homeDirectory}/.local/share/whisper-models"; + model = "ggml-base.bin"; + modelUrl = "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/${model}"; +in +{ + home.packages = [ + whisper-dictation.packages.${hostConfig.platform}.default + ]; + + home.activation.downloadWhisperModel = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + if [ ! -f "${modelDir}/${model}" ]; then + run mkdir -p "${modelDir}" + run ${pkgs.curl}/bin/curl -L -o "${modelDir}/${model}" "${modelUrl}" + fi + ''; + + xdg.configFile."whisper-dictation/config.yaml".text = builtins.toJSON { + whisper = { + model = "base"; + language = "auto"; + }; + hotkey = { + key = "KEY_DOT"; + modifiers = [ "KEY_LEFTMETA" ]; + }; + }; + + systemd.user.services.whisper-dictation = { + Unit = { + Description = "Whisper Dictation speech-to-text daemon"; + After = [ "graphical-session.target" "ydotoold.service" ]; + PartOf = [ "graphical-session.target" ]; + }; + Service = { + ExecStart = "${whisper-dictation.packages.${hostConfig.platform}.default}/bin/whisper-dictation"; + Restart = "on-failure"; + RestartSec = 5; + }; + Install.WantedBy = [ "graphical-session.target" ]; + }; +} diff --git a/hosts/xps15/configuration.nix b/hosts/xps15/configuration.nix index 2d0b521..4062b5d 100644 --- a/hosts/xps15/configuration.nix +++ b/hosts/xps15/configuration.nix @@ -95,10 +95,24 @@ in "libvirt" "storage" "power" + "input" ]; shell = pkgs.zsh; }; + hardware.uinput.enable = true; + + systemd.user.services.ydotoold = { + description = "ydotool daemon"; + wantedBy = [ "graphical-session.target" ]; + partOf = [ "graphical-session.target" ]; + serviceConfig = { + ExecStart = "${pkgs.ydotool}/bin/ydotoold"; + Restart = "on-failure"; + RestartSec = 3; + }; + }; + programs.chromium = { enable = true; extraOpts = {