Created
October 13, 2024 16:26
-
-
Save stv0g/f8d472d6d4df453057fe597cc78abf90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, ... }: | |
let | |
mountPoint = "/media/psf/RosettaLinux"; | |
socket = "/var/cache/rosettad/uds/prlrosettad.sock"; | |
socketDest = "/var/run/prlrosettad.sock"; | |
in | |
{ | |
# https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta | |
nix.settings = { | |
extra-platforms = [ "x86_64-linux" ]; | |
extra-sandbox-paths = [ | |
"/run/binfmt" | |
socketDest | |
mountPoint | |
]; | |
}; | |
boot.binfmt.registrations.rosetta = { | |
interpreter = "${mountPoint}/rosetta"; | |
# The required flags for binfmt are documented by Apple: | |
# https://developer.apple.com/documentation/virtualization/running_intel_binaries_in_linux_vms_with_rosetta | |
magicOrExtension = ''\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00''; | |
mask = ''\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff''; | |
fixBinary = true; | |
matchCredentials = true; | |
preserveArgvZero = false; | |
# Remove the shell wrapper and call the runtime directly | |
wrapInterpreterInShell = false; | |
}; | |
systemd = { | |
services.rosettad = { | |
description = "Rosetta caching daemon"; | |
unitConfig = { | |
RequiresMountsFor = mountPoint; | |
}; | |
serviceConfig = { | |
RuntimeDirectory = "rosettad"; | |
CacheDirectory = "rosettad"; | |
ExecStart = "${mountPoint}/rosettad daemon $CACHE_DIRECTORY"; | |
ExecStartPost = "${pkgs.bash}/bin/bash -c 'while ! [ -S ${socket} ]; do sleep 1; done; ${pkgs.coreutils}/bin/chmod ga+w ${socket}'"; | |
}; | |
}; | |
tmpfiles.rules = [ "L ${socketDest} 0666 - - - ${socket}" ]; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment