roc/shell.nix

117 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 {
2021-04-24 18:49:20 +03:00
name = "nixpkgs-2021-04-23";
url = "https://github.com/nixos/nixpkgs/";
2020-10-24 22:22:51 +03:00
ref = "refs/heads/nixpkgs-unstable";
2021-04-24 18:49:20 +03:00
rev = "8d0340aee5caac3807c58ad7fa4ebdbbdd9134d6";
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
2021-02-16 10:55:50 +03:00
xorg.libxcb
2020-11-30 01:10:04 +03:00
]
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
2021-02-16 10:55:50 +03:00
# lib deps
2020-11-26 06:06:10 +03:00
llvmPkgs.libcxx
llvmPkgs.libcxxabi
2021-02-16 10:55:50 +03:00
libffi
2020-11-26 06:06:10 +03:00
libunwind
2021-02-16 10:55:50 +03:00
libxml2
ncurses
zlib
2021-04-24 18:49:20 +03:00
libiconv
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
2020-11-11 20:55:00 +03:00
# (import ./nix/zls.nix { inherit pkgs zig; })
];
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}";
2021-02-16 10:55:50 +03:00
LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath
([
pkg-config
stdenv.cc.cc.lib
llvmPkgs.libcxx
llvmPkgs.libcxxabi
libunwind
libffi
ncurses
zlib
] ++ linux-inputs);
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