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

made nix flake work for darwin #2902

Merged
merged 6 commits into from
May 23, 2022
Merged
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
2 changes: 0 additions & 2 deletions BUILDING_FROM_SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

### On NixOS

[For NixOS only Linux x86_64 is supported for now](https://github.com/rtfeldman/roc/issues/2734).

NixOS users should make use of the nix flake by [enabling nix flakes](https://nixos.wiki/wiki/Flakes). Shell creation can be done by executing `nix develop` from the root of the repo. NixOS users that do not make use of this flake will get stuck on issue #1846.

### On Linux/MacOS x86_64/aarch64
Expand Down
44 changes: 27 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
rust-overlay.url = "github:oxalica/rust-overlay"; # rust from nixpkgs has some libc problems, this is patched in the rust-overlay
zig.url = "github:roarkanize/zig-overlay"; # zig 8.1 is broken on nixpkgs for M1 macs
zig.url = "github:roarkanize/zig-overlay"; # using an overlay allows for quick updates after zig releases
flake-utils.url = "github:numtide/flake-utils"; # to easily make configs for all architectures
};

Expand All @@ -21,21 +21,32 @@
cwd = builtins.toString ./.;
rust = pkgs.rust-bin.fromRustupToolchainFile "${cwd}/rust-toolchain.toml";

linuxInputs = with pkgs; [
valgrind # used in cli tests, see cli/tests/cli_run.rs
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-validation-layers
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libxcb
alsa-lib
];
linuxInputs = with pkgs;
lib.optionals stdenv.isLinux [
valgrind # used in cli tests, see cli/tests/cli_run.rs
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-validation-layers
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libxcb
alsa-lib
];

darwinInputs = with pkgs;
lib.optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreFoundation
CoreServices
CoreVideo
Foundation
Metal
Security
]);

# zig 0.9.1 from pkgs is broken on aarch64-darwin, hence the workaround
zig-toolchain = zig.packages.${system}."0.9.1";

sharedInputs = (with pkgs; [
Expand All @@ -59,13 +70,12 @@
# faster builds - see https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker
llvmPkgs.lld
# debugir

rust
]);
in {

devShell = pkgs.mkShell {
buildInputs = sharedInputs ++ linuxInputs;
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs;

LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc_multi.out}/lib" else "";
Expand Down