roc/shell.nix

94 lines
2.0 KiB
Nix
Raw Normal View History

2020-10-24 22:22:51 +03:00
{ }:
2020-11-24 09:00:16 +03:00
let
splitSystem = builtins.split "-" builtins.currentSystem;
currentArch = builtins.elemAt splitSystem 0;
currentOS = builtins.elemAt splitSystem 2;
in with {
2020-09-05 23:58:33 +03:00
# Look here for information about how pin version of nixpkgs
2020-01-07 15:27:34 +03:00
# → https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs
2020-10-24 22:22:51 +03:00
pkgs = import (builtins.fetchGit {
name = "nixpkgs-2020-11-24";
url = "https://github.com/nixos/nixpkgs/";
2020-10-24 22:22:51 +03:00
ref = "refs/heads/nixpkgs-unstable";
rev = "6625284c397b44bc9518a5a1567c1b5aae455c08";
2020-01-07 15:27:34 +03:00
}) { };
2020-10-26 00:50:31 +03:00
2020-11-24 09:00:16 +03:00
isMacOS = currentOS == "darwin";
isAarch64 = currentArch == "aarch64";
2020-10-24 22:22:51 +03:00
};
2020-01-07 15:27:34 +03:00
with (pkgs);
2020-01-07 15:27:34 +03:00
let
2020-11-11 20:55:00 +03:00
darwin-frameworks = if isMacOS then
with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreFoundation
CoreServices
CoreVideo
Foundation
Metal
Security
]
else
[ ];
linux-only = if !isMacOS then [
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-validation-layers
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
] else
[ ];
llvmPkgs = pkgs.llvmPackages_10;
2020-11-24 09:00:16 +03:00
zig = import ./nix/zig.nix { inherit pkgs isMacOS isAarch64; };
2020-11-11 20:55:00 +03:00
inputs = [
# build libraries
rustc
cargo
clippy
rustfmt
cmake
git
python3
llvmPkgs.llvm
llvmPkgs.clang
2020-11-11 20:55:00 +03:00
valgrind
pkg-config
zig
# llb deps
libffi
libxml2
zlib
2020-11-26 06:06:10 +03:00
llvmPkgs.libcxx
llvmPkgs.libcxxabi
libunwind
2020-11-11 20:55:00 +03:00
# faster builds - see https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker
llvmPkgs.lld
2020-11-11 20:55:00 +03:00
# dev tools
rust-analyzer
# (import ./nix/zls.nix { inherit pkgs zig; })
ccls
];
in mkShell {
2020-11-11 20:55:00 +03:00
buildInputs = inputs ++ darwin-frameworks ++ linux-only;
LLVM_SYS_100_PREFIX = "${llvmPkgs.llvm}";
2020-10-29 04:22:54 +03:00
2020-11-11 20:55:00 +03:00
APPEND_LIBRARY_PATH = stdenv.lib.makeLibraryPath
2020-11-26 06:06:10 +03:00
([ pkg-config llvmPkgs.libcxx llvmPkgs.libcxxabi libunwind ] ++ linux-only);
2020-10-29 04:22:54 +03:00
# Aliases don't work cross shell, so we do this
2020-10-29 04:17:58 +03:00
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$APPEND_LIBRARY_PATH"
export PATH="$PATH:$PWD/nix/bin"
2020-10-29 04:17:58 +03:00
'';
2020-09-05 23:58:33 +03:00
}