roc/shell.nix

107 lines
2.4 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-2021-01-05";
url = "https://github.com/nixos/nixpkgs/";
2020-10-24 22:22:51 +03:00
ref = "refs/heads/nixpkgs-unstable";
rev = "f53c431645da8e6760268092aa10f736b5cfb117";
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";
2020-11-30 01:10:04 +03:00
isLinux = currentOS == "linux";
2020-11-24 09:00:16 +03:00
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-30 01:10:04 +03:00
darwin-inputs =
if isMacOS then
with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreFoundation
CoreServices
CoreVideo
Foundation
Metal
Security
]
else
[ ];
2020-11-11 20:55:00 +03:00
2020-11-30 01:10:04 +03:00
linux-inputs =
if isLinux then
[
2020-12-03 05:02:52 +03:00
valgrind
2020-11-30 01:10:04 +03:00
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-validation-layers
xorg.libX11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
]
else
[ ];
nixos-env =
if isLinux && builtins.pathExists /etc/nixos/configuration.nix then
{ XDG_DATA_DIRS = "/run/opengl-driver/share:$XDG_DATA_DIRS";
}
else
{ };
2020-11-11 20:55:00 +03:00
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
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
];
2020-11-30 01:10:04 +03:00
in mkShell (nixos-env // {
buildInputs = inputs ++ darwin-inputs ++ linux-inputs;
2020-10-29 04:22:54 +03:00
2020-11-30 01:10:04 +03:00
# Additional Env vars
LLVM_SYS_100_PREFIX = "${llvmPkgs.llvm}";
2020-11-11 20:55:00 +03:00
APPEND_LIBRARY_PATH = stdenv.lib.makeLibraryPath
2020-11-30 01:10:04 +03:00
([ pkg-config llvmPkgs.libcxx llvmPkgs.libcxxabi libunwind ] ++ linux-inputs);
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:$APPEND_LIBRARY_PATH";
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 PATH="$PATH:$PWD/nix/bin"
2020-10-29 04:17:58 +03:00
'';
2020-11-30 01:10:04 +03:00
})
2020-09-05 23:58:33 +03:00