From 6ceb3c508047140816aa6274efd96c3732517b88 Mon Sep 17 00:00:00 2001 From: Jaxxen Date: Mon, 22 Dec 2025 11:24:48 -0600 Subject: [PATCH] Add Nix flake support --- README.md | 32 ++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++ flake.nix | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index f688e52..8cb2d0b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ Linux Voice Activated Macros * [Install](#install) * [Available packages](#available-packages) * [AUR](#aur) + * [Nix flake](#nix-flake) + * [NixOS](#nixos) + * [Other distros](#other-distros) * [Install manually](#install-manually) * [Requirements](#requirements) * [Installation steps](#installation-steps) @@ -53,6 +56,35 @@ If a package is available for your distribution, that's the recommended way for After installing from AUR, run ``sudo usermod -aG tty,input $USER`` to allow [uinput access without sudo](#udev-rule-for-input) and restart your PC. +### Nix flake +You will need ``nix-command`` and ``flakes`` enabled, as well your user being in groups ``input`` and ``tty`` + +Follow the steps below to configure those things for your distro. Once configured, clone this repo, enter it with ``cd LinVAM`` and run ``nix run .`` to use the application. + +#### NixOS +Set the following in your ``configuration.nix`` +``` +# Replace john with your username + +users.users.john.extraGroups = [ + "input" + "tty" +]; + +nix.settings.experimental-features = [ + "nix-command" + "flakes" +]; +``` + +#### Other distros +You can use Nix on nearly any Linux distro, but this section will not explicitly cover how to get Nix itself up and running. There are plenty of good guides out there though (like [this one](https://nix.dev/manual/nix/2.28/installation/index.html)). + +Once Nix is working, run ``sudo usermod -aG input,tty $USER`` and put the following in ``$XDG_CONFIG_HOME/nix/nix.conf`` +``` +experimental-features = nix-command flakes +``` + ### Install manually #### Requirements diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..388be40 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "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" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1766309749, + "narHash": "sha256-3xY8CZ4rSnQ0NqGhMKAy5vgC+2IVK0NoVEzDoOh4DA4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a6531044f6d0bef691ea18d4d4ce44d0daa6e816", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5ec22ff --- /dev/null +++ b/flake.nix @@ -0,0 +1,120 @@ +# flake.nix - Nix flake for building and running LinVAM +# Includes Vosk via prebuilt wheel (x86_64-linux only) + +{ + description = "LinVAM - Linux Voice Activated Macros"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachSystem [ "x86_64-linux" ] (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + python = pkgs.python3; + + voskWheel = pkgs.fetchurl { + url = "https://files.pythonhosted.org/packages/py3/v/vosk/vosk-0.3.45-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl"; + hash = "sha256-JeAlCTxDmdcnj1Q1aO2MxUYKw6S/SMI2c6zh4l0mYZ8="; + }; + + vosk = python.pkgs.buildPythonPackage rec { + pname = "vosk"; + version = "0.3.45"; + format = "wheel"; + + src = voskWheel; + + propagatedBuildInputs = [ ]; + doCheck = false; + + meta = with pkgs.lib; { + description = "Vosk offline speech recognition toolkit"; + homepage = "https://alphacephei.com/vosk/"; + license = licenses.asl20; + platforms = [ "x86_64-linux" ]; + }; + }; + + pythonEnv = python.withPackages (ps: with ps; [ + pyqt6 + sounddevice + srt + requests + tqdm + setuptools + vosk + ]); + in + rec { + formatter = pkgs.nixpkgs-fmt; + + packages.default = pkgs.python3Packages.buildPythonApplication { + pname = "linvam"; + version = "0.8.4"; # Bump on new releases; matches latest tag v0.8.4 + + src = self; + + pyproject = true; + build-system = [ pkgs.python3Packages.setuptools ]; + + propagatedBuildInputs = with pkgs.python3Packages; [ + pyqt6 + sounddevice + srt + requests + tqdm + setuptools + vosk + ]; + + nativeBuildInputs = [ + pkgs.makeWrapper + pkgs.ffmpeg + pkgs.ydotool + ]; + + installPhase = '' + runHook preInstall + ${python.interpreter} setup.py install --prefix=$out --no-compile + runHook postInstall + ''; + + postFixup = '' + wrapProgram $out/bin/linvam \ + --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.ffmpeg pkgs.ydotool ]} + ''; + + meta = with pkgs.lib; { + description = "Linux Voice Activated Macros"; + homepage = "https://github.com/stele95/LinVAM"; + license = licenses.gpl3Only; + platforms = [ "x86_64-linux" ]; + mainProgram = "linvam"; + }; + }; + + devShells.default = pkgs.mkShell { + packages = [ + pythonEnv + pkgs.ffmpeg + pkgs.ydotool + ]; + + shellHook = '' + echo "LinVAM dev environment ready with Vosk included." + echo "Run 'linvam' to test." + ''; + }; + + apps.default = { + type = "app"; + program = "${packages.default}/bin/linvam"; + }; + } + ); +} +