Skip to content

Commit

Permalink
Merge pull request #2902 from rtfeldman/nix_flake_M1
Browse files Browse the repository at this point in the history
made nix flake work for darwin
  • Loading branch information
Anton-4 authored May 23, 2022
2 parents 8fa80fa + b041a5f commit 3caa39f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
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

0 comments on commit 3caa39f

Please sign in to comment.