diff --git a/flake.lock b/flake.lock index 9fc6ab5..d8b0cdc 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1764667669, - "narHash": "sha256-7WUCZfmqLAssbDqwg9cUDAXrSoXN79eEEq17qhTNM/Y=", + "lastModified": 1773734432, + "narHash": "sha256-IF5ppUWh6gHGHYDbtVUyhwy/i7D261P7fWD1bPefOsw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "418468ac9527e799809c900eda37cbff999199b6", + "rev": "cda48547b432e8d3b18b4180ba07473762ec8558", "type": "github" }, "original": { diff --git a/modules/voxtype/check.nix b/modules/voxtype/check.nix new file mode 100644 index 0000000..8e5caee --- /dev/null +++ b/modules/voxtype/check.nix @@ -0,0 +1,16 @@ +{ + pkgs, + self, +}: + +let + voxtypeWrapped = + (self.wrapperModules.voxtype.apply { + inherit pkgs; + }).wrapper; +in +pkgs.runCommand "voxtype-test" { } '' + # this will fail, if the default config is off + "${voxtypeWrapped}/bin/voxtype" config + touch $out +'' diff --git a/modules/voxtype/module.nix b/modules/voxtype/module.nix new file mode 100644 index 0000000..4bc8d0c --- /dev/null +++ b/modules/voxtype/module.nix @@ -0,0 +1,85 @@ +{ + config, + lib, + wlib, + ... +}: +let + tomlFmt = config.pkgs.formats.toml { }; + defaultSettings = { + hotkey = { }; + audio = { + device = "default"; + sample_rate = 16000; + max_duration_secs = 60; + }; + output = { + mode = "type"; + }; + }; +in +{ + _class = "wrapper"; + options = { + settings = lib.mkOption { + type = tomlFmt.type; + default = defaultSettings; + description = '' + Configuration of voxtype. + Default has all minimally required options set.` + ''; + example = + let + pkgs = config.pkgs; + in + { + engine = "parakeet"; + parakeet.model = + let + parakeetBaseUrl = "https://huggingface.co/istupakov/parakeet-tdt-0.6b-v3-onnx/resolve/main"; + in + pkgs.linkFarm "parakeet-tdt-0.6b-v3" [ + { + name = "encoder-model.onnx"; + path = pkgs.fetchurl { + url = "${parakeetBaseUrl}/encoder-model.int8.onnx"; + hash = "sha256-YTnS+n4bCGCXsnfHFJcl7bq4nMfHrmSyPHQb5AVa/wk="; + }; + } + { + name = "decoder_joint-model.onnx"; + path = pkgs.fetchurl { + url = "${parakeetBaseUrl}/decoder_joint-model.int8.onnx"; + hash = "sha256-7qdIPuPRowN12u3I7YPjlgyRsJiBISeg2Z0ciXdmenA="; + }; + } + { + name = "vocab.txt"; + path = pkgs.fetchurl { + url = "${parakeetBaseUrl}/vocab.txt"; + hash = "sha256-1YVEZ56kvGrFY9H1Ret9R0vWz6Rn8KbiwdwcfTfjw10="; + }; + } + { + name = "config.json"; + path = pkgs.fetchurl { + url = "${parakeetBaseUrl}/config.json"; + hash = "sha256-ZmkDx2uXmMrywhCv1PbNYLCKjb+YAOyNejvA0hSKxGY="; + }; + } + ]; + hotkey.enabled = false; + }; + }; + "voxtype.toml" = lib.mkOption { + type = wlib.types.file config.pkgs; + default.path = tomlFmt.generate "voxtype.toml" (defaultSettings // config.settings); + }; + }; + config.flags = { + "--config" = toString config."voxtype.toml".path; + }; + config.package = config.pkgs.voxtype; + config.meta.maintainers = [ lib.maintainers.lenny ]; + config.meta.platforms = lib.platforms.linux; # voxtype not packaged on darwin atm +}