home: set up git-maintenance daemon

This commit is contained in:
Oystein Kristoffer Tveit 2024-06-30 14:39:36 +02:00
parent 47c0ee8b68
commit 9db1b7f2e3
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 87 additions and 2 deletions

View File

@ -21,6 +21,8 @@ in {
./programs/tmux.nix
./programs/zsh
./services/git-maintenance.nix
./modules/colors.nix
./modules/shellAliases.nix
] ++ optionals graphics [

View File

@ -0,0 +1,77 @@
{ config, pkgs, lib, ... }:
{
systemd.user.services."git-maintenance@" = {
Unit = {
Description = "Optimize Git repositories data";
Documentation = [ "man:git-maintenance(1)" ];
};
Service = {
Type = "oneshot";
ExecStart = "${lib.getExe pkgs.git} for-each-repo --config=maintenance.repo maintenance run --schedule=%i";
LockPersonality = "yes";
MemoryDenyWriteExecute = "yes";
NoNewPrivileges = "yes";
RestrictAddressFamilies = [
"AF_UNIX"
"AF_INET"
"AF_INET6"
"AF_VSOCK"
];
RestrictNamespaces = "yes";
RestrictRealtime = "yes";
RestrictSUIDSGID = "yes";
SystemCallArchitectures = "native";
SystemCallFilter = "@system-service";
};
};
systemd.user.timers."git-maintenance@hourly" = {
Unit = {
Description = "Optimize Git repositories data";
Documentation = [ "man:git-maintenance(1)" ];
};
Timer = {
OnCalendar = "*-*-* 1..23:05:00";
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
systemd.user.timers."git-maintenance@daily" = {
Unit = {
Description = "Optimize Git repositories data";
Documentation = [ "man:git-maintenance(1)" ];
};
Timer = {
OnCalendar = "Tue..Sun *-*-* 0:05:00";
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
systemd.user.timers."git-maintenance@weekly" = {
Unit = {
Description = "Optimize Git repositories data";
Documentation = [ "man:git-maintenance(1)" ];
};
Timer = {
OnCalendar = "Mon 0:05:00";
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
}

View File

@ -1,4 +1,10 @@
{ ... }:
{ config, ... }:
{
programs.git.extraConfig.maintenance.repo = let
home = config.home.homeDirectory;
in [
"${home}/nix"
"${home}/nixpkgs"
"${home}/pvv/nix"
];
}