nix-gc: remove redundant platform checks

This commit is contained in:
Benedikt Rips
2026-01-05 17:17:00 +01:00
parent a26335db1b
commit 2379f704b0

View File

@@ -83,56 +83,51 @@ in
}; };
}; };
config = lib.mkIf cfg.automatic ( config = lib.mkIf cfg.automatic {
lib.mkMerge [ systemd.user.services.nix-gc = {
(lib.mkIf pkgs.stdenv.isLinux { Unit = {
systemd.user.services.nix-gc = { Description = "Nix Garbage Collector";
Unit = { };
Description = "Nix Garbage Collector"; Service = {
}; Type = "oneshot";
Service = { ExecStart = pkgs.writeShellScript "nix-gc" "exec ${nixPackage}/bin/nix-collect-garbage ${
Type = "oneshot"; lib.optionalString (cfg.options != null) cfg.options
ExecStart = pkgs.writeShellScript "nix-gc" "exec ${nixPackage}/bin/nix-collect-garbage ${ }";
lib.optionalString (cfg.options != null) cfg.options };
}"; };
};
};
systemd.user.timers.nix-gc = {
Unit = {
Description = "Nix Garbage Collector";
};
Timer = {
OnCalendar = cfg.dates;
RandomizedDelaySec = cfg.randomizedDelaySec;
Persistent = cfg.persistent;
Unit = "nix-gc.service";
};
Install = {
WantedBy = [ "timers.target" ];
};
};
})
(lib.mkIf pkgs.stdenv.isDarwin { systemd.user.timers.nix-gc = {
assertions = [ Unit = {
{ Description = "Nix Garbage Collector";
assertion = (lib.length cfg.dates) == 1; };
message = "On Darwin, `nix.gc.dates` must contain a single element."; Timer = {
} OnCalendar = cfg.dates;
(lib.hm.darwin.assertInterval "nix.gc.dates.*" (lib.elemAt cfg.dates 0) pkgs) RandomizedDelaySec = cfg.randomizedDelaySec;
]; Persistent = cfg.persistent;
Unit = "nix-gc.service";
};
Install = {
WantedBy = [ "timers.target" ];
};
};
launchd.agents.nix-gc = { assertions = [
enable = true; {
config = { assertion = pkgs.stdenv.isDarwin -> (lib.length cfg.dates == 1);
ProgramArguments = [ message = "On Darwin, `nix.gc.dates` must contain a single element.";
"${nixPackage}/bin/nix-collect-garbage" }
] (lib.hm.darwin.assertInterval "nix.gc.dates.*" (lib.elemAt cfg.dates 0) pkgs)
++ lib.optional (cfg.options != null) cfg.options; ];
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval (lib.elemAt cfg.dates 0);
}; launchd.agents.nix-gc = {
}; enable = true;
}) config = {
] ProgramArguments = [
); "${nixPackage}/bin/nix-collect-garbage"
]
++ lib.optional (cfg.options != null) cfg.options;
StartCalendarInterval = lib.hm.darwin.mkCalendarInterval (lib.elemAt cfg.dates 0);
};
};
};
} }