-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
darling: init at unstable-2023-05-02 #227765
Conversation
7537f60
to
3058b3d
Compare
The previous |
78ff73c
to
61a2046
Compare
During the build, Darling produces a source-built SDK which is now installed into a separate output. This SDK can be used to cross-compile from Linux to macOS (see the NixOS test). I tried the resulting executable and it worked fine on a real M1 Mac mini under Rosetta 2. Very hacky cross stdenvlet
lib = import ./lib;
pkgs = import ./. {
crossSystem = lib.systems.elaborate (lib.systems.examples.x86_64-darwin // {
darwinSdkVersion = "10.15";
darwinMinVersion = "10.15";
});
overlays = [ (final: prev: {
stdenv =
if (prev.stdenv.hostPlatform == prev.stdenv.buildPlatform) then prev.stdenv
else prev.stdenv.override {
overrides = overrideStdenv;
};
}) ];
};
overrideStdenv = final: prev: let
nativePkgs = prev.pkgsBuildBuild;
llvm = nativePkgs.llvmPackages_latest;
sdk = "${nativePkgs.darling.sdk}/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk";
nativeStuff = {
nativeTools = false;
nativeLibc = false;
nativePrefix = "";
shell = nativePkgs.stdenvNoCC.shell;
inherit (nativePkgs) coreutils gnugrep;
};
mergedBintools = nativePkgs.symlinkJoin {
name = "bintools-unwrapped";
paths = [ llvm.bintools-unwrapped ];
postBuild = ''
ln -sf ${nativePkgs.darling.sdk}/bin/x86_64-apple-darwin19-ld $out/bin/ld
'';
};
bintools = prev.wrapBintoolsWith ({
bintools = mergedBintools;
libc = "${sdk}/usr";
} // nativeStuff);
cc = prev.wrapCCWith (rec {
cc = llvm.clang-unwrapped;
inherit bintools;
libc = "${sdk}/usr";
libcxx = null;
isClang = true;
gccForLibs = null;
extraBuildCommands = ''
echo "--sysroot=${sdk}" >> $out/nix-support/cc-cflags
rsrc="$out/resource-root"
mkdir "$rsrc"
ln -s "${cc.lib or cc}/lib/clang/${cc.version}/include" "$rsrc"
echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
'';
} // nativeStuff);
stdenv = prev.stdenv.override {
inherit cc;
extraBuildInputs = [];
};
in {
inherit stdenv;
};
in pkgs |
@ofborg test darling |
# darling-dmg | ||
fuse | ||
|
||
# CoreAudio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are asking about the comments, these are supposed to indicate which components the wrapped libraries are used in. I'll make that clearer.
Description of changes
This PR adds Darling which is a Darwin/macOS emulation layer for Linux.
Patches applied:
Fixes #38628.
Installing
Set
programs.darling.enable = true;
in your NixOS config. This will install the setuid wrapper necessary to start Darling. Then, rundarling shell
.Stuff To Try
See also https://docs.darlinghq.org/what-to-try.html
Nix
The official Nix install script does not work on Darling due to its attempts to modify partitions and users on the system. Nix also has trouble clearing file attributes in the emulated filesystem.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)