Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__
build
dist
scribe/_version.py
.direnv/
103 changes: 103 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
description = "Scribe application using uv2nix";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

pyproject-nix = {
url = "github:pyproject-nix/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};

uv2nix = {
url = "github:pyproject-nix/uv2nix";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};

pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.uv2nix.follows = "uv2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { nixpkgs, pyproject-nix, uv2nix, pyproject-build-systems, ... }:
let
inherit (nixpkgs) lib;
forAllSystems = lib.genAttrs lib.systems.flakeExposed;

workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };

overlay = workspace.mkPyprojectOverlay { sourcePreference = "wheel"; };

editableOverlay =
workspace.mkEditablePyprojectOverlay { root = "$REPO_ROOT"; };

pythonSets = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python313;
pyprojectOverrides = final: prev:
let hacks = final.pkgs.callPackage pyproject-nix.build.hacks { };
in {
# Use nixpkgs versions to avoid building from source
pycairo = hacks.nixpkgsPrebuilt {
from = final.pkgs.python3Packages.pycairo;
prev = prev.pycairo;
};
# pygobject in PyPI is pygobject3 in nixpkgs
pygobject = hacks.nixpkgsPrebuilt {
from = final.pkgs.python3Packages.pygobject3;
prev = prev.pygobject;
};
# evdev has no Linux wheels
evdev = hacks.nixpkgsPrebuilt {
from = final.pkgs.python3Packages.evdev;
prev = prev.evdev;
};
# srt doesn't declare setuptools as build dependency
srt = hacks.nixpkgsPrebuilt {
from = final.pkgs.python3Packages.srt;
prev = prev.srt;
};
};
in (pkgs.callPackage pyproject-nix.build.packages {
inherit python;
}).overrideScope (lib.composeManyExtensions [
pyproject-build-systems.overlays.wheel
overlay
pyprojectOverrides
]));

in {
devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pythonSet = pythonSets.${system}.overrideScope editableOverlay;
virtualenv = pythonSet.mkVirtualEnv "scribe-dev-env" {
scribe = [ "app" "keyboard" "vosk" ];
};
in {
default = pkgs.mkShell {
packages = [ virtualenv pkgs.uv ];
env = {
UV_NO_SYNC = "1";
UV_PYTHON = pythonSet.python.interpreter;
UV_PYTHON_DOWNLOADS = "never";
};
shellHook = ''
unset PYTHONPATH
export REPO_ROOT=$(git rev-parse --show-toplevel)
'';
};
});

packages = forAllSystems (system: {
default = pythonSets.${system}.mkVirtualEnv "scribe-env" {
scribe = [ "app" "keyboard" "vosk" ];
};
});
};
}
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0", "setuptools_scm[toml]>=6.2", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "scribe-cli"
name = "scribe"
dynamic = ["version"]
description = "scribe is a local speech recognition tool that provides real-time transcription using vosk and whisper AI, with the goal of serving as a virtual keyboard on a computer"
authors = [
Expand Down Expand Up @@ -54,6 +54,12 @@ app = ["pystray", "PyGObject"]
openai = ["openai", "soundfile"]
all = ["pynput", "openai-whisper", "openai", "soundfile", "vosk", "pystray"]

[tool.uv]
dev-dependencies = []

[tool.uv.extra-build-dependencies]
pycairo = ["mesonpy"]


[tool.setuptools]
packages = [ "scribe", "scribe_data" ]
Expand Down
Loading