darling: init at unstable-2023-05-02#227765
Merged
Merged
Conversation
Closed
Atemu
reviewed
Apr 23, 2023
ShamrockLee
reviewed
Apr 23, 2023
7537f60 to
3058b3d
Compare
AndersonTorres
suggested changes
Apr 23, 2023
Member
Author
|
The previous |
AndersonTorres
suggested changes
Apr 23, 2023
12 tasks
Kranzes
reviewed
Apr 27, 2023
78ff73c to
61a2046
Compare
Member
Author
|
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 |
Member
Author
|
@ofborg test darling |
AndersonTorres
suggested changes
May 4, 2023
Member
Author
There was a problem hiding this comment.
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 = trueset 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/)