Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module: add rosetta2-gc #1165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,5 @@
./programs/zsh
./homebrew.nix
./users
./virtualisation/rosetta/gc.nix
]
61 changes: 61 additions & 0 deletions modules/virtualisation/rosetta/gc.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}