Skip to content
Merged
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
53 changes: 53 additions & 0 deletions nixos/commit-notifier.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ in {
RUST_LOG environment variable;
'';
};
maintenance = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to consolidate the git packfiles of the tracked repositories.
Every fetch of new objects writes another packfile, and nothing else
consolidates them, so the number of packfiles would otherwise grow
without bound and slow every fetch down.
'';
};
calendar = lib.mkOption {
type = lib.types.str;
default = "daily";
description = ''
When to consolidate the git packfiles of the tracked repositories.
'';
};
};
};

config = lib.mkIf cfg.enable {
Expand Down Expand Up @@ -97,5 +116,39 @@ in {
group = "commit-notifier";
};
users.groups.commit-notifier = {};

systemd.services.commit-notifier-maintenance = lib.mkIf cfg.maintenance.enable {
description = "Consolidate git packfiles of commit-notifier repositories";

script = ''
shopt -s nullglob
for repo in /var/lib/commit-notifier/repositories/*/repo; do
echo "repacking $repo"
git -C "$repo" repack --geometric=2 -d --write-midx -q
done
'';

path = [
pkgs.git
];

serviceConfig = {
User = "commit-notifier";
Group = "commit-notifier";
StateDirectory = "commit-notifier";
Type = "oneshot";
Nice = 10;
IOSchedulingClass = "idle";
};
};

systemd.timers.commit-notifier-maintenance = lib.mkIf cfg.maintenance.enable {
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = cfg.maintenance.calendar;
Persistent = true;
RandomizedDelaySec = "1h";
};
};
};
}
Loading