-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
155 lines (140 loc) · 4.86 KB
/
flake.nix
File metadata and controls
155 lines (140 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{
description = "NVIDIA Parakeet ASR development environment with CUDA support";
inputs = {
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
devenv.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-public-keys = [
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
extra-substituters = [
"https://devenv.cachix.org"
"https://cuda-maintainers.cachix.org"
];
};
outputs = {
self,
nixpkgs,
devenv,
systems,
...
} @ inputs: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
devShells =
forEachSystem
(system: let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
cudaSupport = true;
# RTX 4090 = Ada Lovelace = sm_89
cudaCapabilities = ["8.9"];
};
};
in {
default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
({
pkgs,
lib,
config,
...
}: {
# Core packages
packages = with pkgs; [
# Audio
portaudio # sounddevice backend (connects to PulseAudio/PipeWire)
pulseaudio # CLI tools (parecord, pactl)
ffmpeg
sox
# Text input simulation (Wayland)
ydotool
wl-clipboard
# Dev tools
git
curl
jq
];
# Python with CUDA support
languages.python = {
enable = true;
package = pkgs.python313.withPackages (ps:
with ps; [
pip
setuptools
wheel
uv
]);
uv = {
enable = true;
sync.enable = true;
};
};
# CUDA environment
env = {
# Point to CUDA libraries
CUDA_PATH = "${pkgs.cudaPackages.cudatoolkit}";
CUDNN_PATH = "${pkgs.cudaPackages.cudnn}";
# Store the library path for CUDA apps, but don't set LD_LIBRARY_PATH globally
# (setting it globally breaks system binaries like hyprctl)
CUDA_LD_LIBRARY_PATH = lib.makeLibraryPath [
pkgs.cudaPackages.cudatoolkit
pkgs.cudaPackages.cudnn
pkgs.stdenv.cc.cc.lib
pkgs.zlib
pkgs.portaudio
"/run/opengl-driver" # NixOS nvidia driver location
];
# For PyTorch/NeMo compilation
TORCH_CUDA_ARCH_LIST = "8.9"; # Ada Lovelace (4090)
# Suppress warnings
TF_CPP_MIN_LOG_LEVEL = "2";
};
# Shell initialization
enterShell = ''
echo "🎤 Parakeet ASR Development Environment"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Python: $(python --version)"
echo "CUDA: ${pkgs.cudaPackages.cudatoolkit.version}"
echo "cuDNN: ${pkgs.cudaPackages.cudnn.version}"
# Check for GPU
if command -v nvidia-smi &> /dev/null; then
echo "GPU: $(nvidia-smi --query-gpu=name --format=csv,noheader | head -1)"
fi
echo ""
echo "Run 'uv sync' to install Python dependencies"
echo "Use 'cuda-uv run ...' or 'cuda-python ...' for CUDA apps"
'';
# CUDA wrapper scripts
#
# NixOS doesn't set LD_LIBRARY_PATH globally (breaks system binaries),
# so we wrap commands that need CUDA libraries.
#
# Available commands:
# barkdown - Run the app with CUDA support
# cuda-python - Run Python with CUDA libraries
# cuda-uv - Run uv commands with CUDA libraries
scripts = {
cuda-python.exec = ''
LD_LIBRARY_PATH="$CUDA_LD_LIBRARY_PATH" python "$@"
'';
cuda-uv.exec = ''
LD_LIBRARY_PATH="$CUDA_LD_LIBRARY_PATH" uv "$@"
'';
barkdown.exec = ''
LD_LIBRARY_PATH="$CUDA_LD_LIBRARY_PATH" uv run barkdown "$@"
'';
};
})
];
};
});
};
}