-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathflake.nix
174 lines (146 loc) · 3.99 KB
/
flake.nix
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{
description = "transcribee monorepo";
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";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
uv2nix,
pyproject-nix,
pyproject-build-systems,
flake-utils,
self,
...
}:
let
pythonPkgName = "python311";
in
{
overlays.default = (
final: prev:
let
pkgs = import nixpkgs {
system = final.system;
};
lib = nixpkgs.lib;
python = pkgs."${pythonPkgName}";
in
{
transcribee-worker = import ./nix/pkgs/worker.nix {
inherit
pkgs
lib
python
uv2nix
pyproject-nix
pyproject-build-systems
;
};
transcribee-backend = import ./nix/pkgs/backend.nix {
inherit
pkgs
lib
python
uv2nix
pyproject-nix
pyproject-build-systems
;
};
transcribee-frontend = import ./nix/pkgs/frontend.nix {
inherit pkgs lib;
versionInfo = {
commitHash = if (self ? rev) then self.rev else self.dirtyRev;
commitDate = self.lastModified;
};
};
}
);
nixosModules.default = {
nixpkgs.overlays = [ self.overlays.default ];
};
}
// (flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
python = pkgs."${pythonPkgName}";
ld_packages = [
pkgs.file # provides libmagic
# for ctranslate2
pkgs.stdenv.cc.cc.lib
];
in
{
packages = {
backend = pkgs.transcribee-backend;
worker = pkgs.transcribee-worker;
frontend = pkgs.transcribee-frontend;
};
formatter = pkgs.nixfmt-rfc-style;
devShells.default = pkgs.mkShell {
packages = [
python
pkgs.uv
python.pkgs.black
pkgs.poethepoet
pkgs.overmind
pkgs.wait4x
pkgs.pre-commit
pkgs.nodejs_20
# nix tooling
pkgs.nixpkgs-fmt
# required by whispercppy
pkgs.cmake
# required by pre-commit
pkgs.git
pkgs.ruff
# required by psycopg2
pkgs.openssl
pkgs.ffmpeg
# for automerge-py
pkgs.libiconv
pkgs.rustc
pkgs.cargo
pkgs.icu.dev
# Our database
pkgs.postgresql_14
# Our database2 ?
pkgs.redis
pkgs.glibcLocales
];
shellHook =
''
unset PYTHONPATH
export UV_PYTHON_DOWNLOADS=never
export TRANSCRIBEE_DYLD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath ld_packages}
export LD_LIBRARY_PATH=$LD_SEARCH_PATH:$TRANSCRIBEE_DYLD_LIBRARY_PATH
''
+ pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
export CPPFLAGS="-I${pkgs.libcxx.dev}/include/c++/v1"
# `dyld` needs to find the libraries
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH
'';
};
}
));
}