parsed=$(systemd-analyze timespan ${escapeShellArg duration} | awk '$1 == "μs:" { print $2 }')
echo "$parsed" > "$out"
'';
- gather_home_profiles = lib.optionalString cfg.manageHomeProfiles ''
+ gather_home_profiles = ''
while read -r home_dir;do
home_profile_dir="$home_dir/.local/state/nix/profiles"
if [[ -d "$home_profile_dir" ]];then
options = {
nix.profile-gc = {
enable = lib.mkEnableOption "Automatic profile garbage collection";
+ monitorHomeProfiles = lib.mkOption {
+ description = "Monitor profiles in users' $HOME/.local/state/nix/profiles/";
+ type = lib.types.bool;
+ default = true;
+ };
manageHomeProfiles = lib.mkOption {
description = "Manage profiles in users' $HOME/.local/state/nix/profiles/";
type = lib.types.bool;
assertion = cfg.enable -> config.nix.gc.automatic;
message = ''nix.profile-gc.enable requires nix.gc.automatic'';
}
+ {
+ assertion = cfg.manageHomeProfiles -> cfg.monitorHomeProfiles;
+ message = ''nix.profile-gc.manageHomeProfiles requires nix.profile-gc.monitorHomeProfiles'';
+ }
];
systemd.services.nix-gc.serviceConfig.ExecStartPre = pkgs.writeShellScript "nix-profile-gc" ''
set -euo pipefail
)
home_profile_dirs=()
- ${gather_home_profiles}
+ ${lib.optionalString cfg.manageHomeProfiles gather_home_profiles}
now=$(${pkgs.coreutils}/bin/date +%s)
age_threshold="$(< ${parse-duration cfg.keepLatest})"
serviceConfig.Type = "oneshot";
script = ''
home_profile_dirs=()
- ${gather_home_profiles}
+ ${lib.optionalString cfg.monitorHomeProfiles gather_home_profiles}
${pkgs.coreutils}/bin/mkdir -p ${cfg.logdir}
${pkgs.coreutils}/bin/readlink /run/current-system >> ${cfg.logdir}/active-system