forked from ActivityWatch/activitywatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
281 lines (247 loc) · 7.41 KB
/
Copy pathflake.nix
File metadata and controls
281 lines (247 loc) · 7.41 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
{
description = "ActivityWatch — The free and open-source automated time tracker";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
systems.url = "github:nix-systems/default";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
pyproject-nix = {
url = "github:pyproject-nix/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs.pyproject-nix.follows = "pyproject-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [ inputs.treefmt-nix.flakeModule ];
perSystem =
{
config,
pkgs,
lib,
system,
...
}:
let
pythonVersion = "python312";
pythonPkgs = pkgs.${pythonVersion}.pkgs;
version = self.rev or self.dirtyRev or "dev";
awSubmodules = [
"aw-core"
"aw-client"
"aw-server"
"aw-qt"
"aw-watcher-afk"
"aw-watcher-window"
];
awExtras = [
"aw-notify"
"aw-watcher-input"
];
src =
let
filesets = lib.fileset.unions (
[
./pyproject.toml
./poetry.lock
./Makefile
./aw.spec
]
++ map (name: ./${name}) (awSubmodules ++ awExtras)
);
in
lib.fileset.toSource {
root = ./.;
fileset = filesets;
};
rustToolchain =
let
rustOverlay = inputs.rust-overlay.overlays.default;
pkgsWithRust = import inputs.nixpkgs {
inherit system;
overlays = [ rustOverlay ];
};
in
pkgsWithRust.rust-bin.stable.latest.default;
aw-server-rust =
if (builtins.pathExists ./aw-server-rust/Cargo.toml) then
inputs.naersk.lib.${system}.buildPackage {
root = ./aw-server-rust;
src = lib.fileset.toSource {
root = ./aw-server-rust;
fileset = lib.fileset.unions [
./aw-server-rust/Cargo.toml
./aw-server-rust/Cargo.lock
./aw-server-rust/src
];
};
cargoBuildOptions = opts: opts ++ [ "--release" ];
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
}
else
null;
activitywatchPythonEnv = pkgs.${pythonVersion}.withPackages (
ps: with ps; [
urllib3
pytest
pytest-cov
pytest-benchmark
mypy
psutil
]
);
runtimeDeps = with pkgs; [
libsForQt5.qtbase
libsForQt5.qtwayland
libsForQt5.qtx11extras
xorg.libxcb
xorg.libX11
xorg.libXcursor
xorg.libXext
xorg.libXfixes
xorg.libXft
xorg.libXi
xorg.libXrandr
xorg.libXrender
fontconfig.lib
freetype
];
in
{
treefmt = {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
prettier.enable = true;
};
};
packages = {
default = pkgs.symlinkJoin {
name = "activitywatch-${version}";
paths = [
pkgs.${pythonVersion}
activitywatchPythonEnv
]
++ lib.optional (aw-server-rust != null) aw-server-rust;
meta = with lib; {
description = "ActivityWatch — automated time tracker";
homepage = "https://activitywatch.net";
license = licenses.mpl20;
mainProgram = "aw-qt";
platforms = platforms.linux ++ platforms.darwin;
};
};
}
// lib.optionalAttrs (aw-server-rust != null) {
inherit aw-server-rust;
};
devShells = {
default = pkgs.mkShell {
packages = [
pkgs.${pythonVersion}
]
++ (with pkgs; [
poetry
# Node.js (for web UI)
nodejs_22
# Build tools
pkg-config
gcc
# Qt dependencies
libsForQt5.qtbase
libsForQt5.qtwayland
libsForQt5.qtx11extras
# X11/dev libraries
xorg.libxcb
xorg.libX11
xorg.libXcursor
xorg.libXext
xorg.libXfixes
xorg.libXft
xorg.libXi
xorg.libXrandr
xorg.libXrender
fontconfig.lib
freetype
openssl
# Linting & formatting
ruff
mypy
# Tools
git
jq
])
++ lib.optional (aw-server-rust != null) rustToolchain;
LD_LIBRARY_PATH = lib.makeLibraryPath runtimeDeps;
shellHook = ''
echo "ActivityWatch dev shell (version: ${version})"
echo "Python: $(python --version)"
echo "Node: $(node --version)"
'';
};
ci = pkgs.mkShellNoCC {
packages = [
pkgs.${pythonVersion}
]
++ (with pkgs; [
poetry
nodejs_22
pkg-config
gcc
git
jq
]);
};
};
checks = {
build = config.packages.default;
format = config.treefmt.build.check self;
devshell = config.devShells.default;
};
};
flake.overlays.default = final: _prev: {
activitywatch = final.symlinkJoin {
name = "activitywatch-${final.lib.substring 0 7 (self.rev or self.dirtyRev or "dev")}";
paths = [
final.python312
final.python312.withPackages
(
ps: with ps; [
urllib3
pytest
pytest-cov
mypy
]
)
];
meta = with final.lib; {
description = "ActivityWatch — automated time tracker";
homepage = "https://activitywatch.net";
license = licenses.mpl20;
mainProgram = "aw-qt";
};
};
};
};
}