feat(ebook-search): set up uv cache management and pruning service
treefmt / nix fmt (pull_request) Successful in 5s
pytest / pytest (pull_request) Successful in 27s
test ebook search / test-ebook-search (pull_request) Successful in 34s
build_systems / build-brain (pull_request) Successful in 48s
build_systems / build-bob (pull_request) Successful in 50s
build_systems / build-rhapsody-in-green (pull_request) Successful in 1m3s
build_systems / build-jeeves (pull_request) Successful in 2m14s
treefmt / nix fmt (push) Successful in 4s
test ebook search / test-ebook-search (push) Successful in 27s
pytest / pytest (push) Successful in 30s
build_systems / build-brain (push) Successful in 34s
build_systems / build-bob (push) Successful in 37s
build_systems / build-jeeves (push) Successful in 2m9s
build_systems / build-rhapsody-in-green (push) Successful in 48s

This commit was merged in pull request #40.
This commit is contained in:
2026-07-12 17:26:55 -04:00
parent 91575e3ab2
commit 8c3de690c9
8 changed files with 65 additions and 14 deletions
+2
View File
@@ -11,6 +11,8 @@ on:
env:
UV_PYTHON_DOWNLOADS: never
UV_CACHE_DIR: /var/cache/uv
UV_LINK_MODE: copy
jobs:
test-ebook-search:
+3 -3
View File
@@ -36,11 +36,11 @@ docker compose -f python/ebook_search/docker/docker-compose.yml ps
The image builds its environment with uv from `pyproject.toml` + `uv.lock` in this
directory — this is the source of truth for the container's dependencies. To add or
update a dependency, edit `pyproject.toml` here and regenerate the lock (requires uv
on the host; it is not in the nix dev shell):
update a dependency, edit `pyproject.toml` here and regenerate the lock (uv is
available in the `ebook-search` dev shell):
```sh
cd python/ebook_search/docker && uv lock
nix develop .#ebook-search -c uv lock --project python/ebook_search/docker
```
## Tests
+4 -1
View File
@@ -1,6 +1,9 @@
{ ... }:
{
imports = [ ./nix_builder.nix ];
imports = [
./nix_builder.nix
./uv_cache_prune.nix
];
services.nix_builder.containers = {
nix-builder-00.enable = true;
+12 -2
View File
@@ -62,6 +62,11 @@ in
mountPoint = "/run/secrets/gitea-runners";
isReadOnly = true;
};
uv-cache = {
hostPath = vars.uv_cache;
mountPoint = "/var/cache/uv";
isReadOnly = false;
};
};
config =
{
@@ -138,7 +143,6 @@ in
nixos-rebuild
nodejs
treefmt
uv
wget
];
};
@@ -154,7 +158,8 @@ in
}
) cfg.containers;
systemd.services = builtins.listToAttrs (
systemd = {
services = builtins.listToAttrs (
map (name: {
name = "container@${name}";
value = {
@@ -163,5 +168,10 @@ in
};
}) (builtins.attrNames (filterAttrs (_: c: c.enable) cfg.containers))
);
tmpfiles.rules = [
"d ${vars.uv_cache} 0755 ${runnerUsername} ${runnerUsername} - -"
];
};
};
}
+28
View File
@@ -0,0 +1,28 @@
{ pkgs, ... }:
let
vars = import ../vars.nix;
runnerUsername = "gitea-runner";
in
{
systemd = {
services.uv-cache-prune = {
description = "Prune the shared gitea runner uv cache";
environment.UV_CACHE_DIR = vars.uv_cache;
serviceConfig = {
Type = "oneshot";
User = runnerUsername;
Group = runnerUsername;
ExecStart = "${pkgs.uv}/bin/uv cache prune";
};
};
timers.uv-cache-prune = {
description = "Monthly prune of the shared gitea runner uv cache";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*-*-01 04:00:00";
Persistent = true;
};
};
};
}
+1
View File
@@ -30,6 +30,7 @@ sudo zfs create media/secure/share -o mountpoint=/zfs/media/share -o exec=off
# scratch datasets
sudo zfs create scratch/kafka -o mountpoint=/zfs/scratch/kafka -o recordsize=1M
sudo zfs create scratch/transmission -o mountpoint=/zfs/scratch/transmission -o recordsize=16k -o sync=disabled -o redundant_metadata=none
sudo zfs create scratch/uv_cache -o mountpoint=/zfs/scratch/uv_cache
# storage datasets
sudo zfs create storage/ollama -o recordsize=1M -o compression=zstd-19 -o sync=disabled
+6
View File
@@ -121,3 +121,9 @@ monthly = 2
hourly = 0
daily = 0
monthly = 0
["scratch/uv_cache"]
15_min = 2
hourly = 0
daily = 0
monthly = 0
+1
View File
@@ -17,5 +17,6 @@ in
transmission = "${zfs_storage}/transmission";
ollama = "${zfs_storage}/ollama";
transmission_scratch = "${zfs_scratch}/transmission";
uv_cache = "${zfs_scratch}/uv_cache";
kafka = "${zfs_scratch}/kafka";
}