mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-14 11:57:34 +00:00
module: add rosetta2 garbage collection service
Provides a service to prune the Rosetta 2 JIT bytecode cache.
This commit is contained in:
parent
5c74ab862c
commit
9e494016ba
2 changed files with 62 additions and 0 deletions
|
@ -109,4 +109,5 @@
|
|||
./programs/zsh
|
||||
./homebrew.nix
|
||||
./users
|
||||
./virtualisation/rosetta/gc.nix
|
||||
]
|
||||
|
|
61
modules/virtualisation/rosetta/gc.nix
Normal file
61
modules/virtualisation/rosetta/gc.nix
Normal file
|
@ -0,0 +1,61 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
;
|
||||
|
||||
launchdTypes = import ../../launchd/types.nix { inherit config lib; };
|
||||
|
||||
logFile = "/var/log/rosetta-gc.log";
|
||||
|
||||
cfg = config.virtualisation.rosetta.gc;
|
||||
in
|
||||
|
||||
{
|
||||
options.virtualisation.rosetta.gc = {
|
||||
enable = mkEnableOption "Rosetta 2 JIT cache garbage collection";
|
||||
|
||||
interval = mkOption {
|
||||
type = launchdTypes.StartCalendarInterval;
|
||||
default = [
|
||||
{
|
||||
Weekday = 6;
|
||||
Hour = 3;
|
||||
Minute = 15;
|
||||
}
|
||||
];
|
||||
description = ''
|
||||
The calendar interval at which the garbage collector will run.
|
||||
See the {option}`serviceConfig.StartCalendarInterval` option of
|
||||
the {option}`launchd` module for more info.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
launchd.daemons.rosetta-gc = {
|
||||
script = ''
|
||||
date
|
||||
/System/Library/Filesystems/apfs.fs/Contents/Resources/apfs.util -P -minsize 0 /System/Volumes/Data
|
||||
'';
|
||||
serviceConfig = {
|
||||
RunAtLoad = true;
|
||||
StartCalendarInterval = cfg.interval;
|
||||
StandardErrorPath = logFile;
|
||||
StandardOutPath = logFile;
|
||||
};
|
||||
};
|
||||
|
||||
environment.etc."newsyslog.d/rosetta-gc.conf".text = ''
|
||||
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
|
||||
${logFile} 640 10 * $W0 NJ
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue