feat(tmpfiles): defer per-service file permissions to reduce boot time

This commit is contained in:
2026-02-12 18:48:29 -05:00
parent 84cbe82cb0
commit 82add97a80
19 changed files with 139 additions and 53 deletions

View File

@@ -155,5 +155,28 @@ inputs.nixpkgs.lib.extend (
# }
#];
};
serviceFilePerms =
serviceName: tmpfilesRules:
{ pkgs, ... }:
let
confFile = pkgs.writeText "${serviceName}-file-perms.conf" (lib.concatStringsSep "\n" tmpfilesRules);
in
{
systemd.services."${serviceName}-file-perms" = {
after = [ "${serviceName}-mounts.service" ];
before = [ "${serviceName}.service" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.systemd}/bin/systemd-tmpfiles --create ${confFile}";
};
};
systemd.services.${serviceName} = {
wants = [ "${serviceName}-file-perms.service" ];
after = [ "${serviceName}-file-perms.service" ];
};
};
}
)