2021-10-30 15:44:17 +03:00
|
|
|
{ }:
|
2022-07-26 18:21:51 +03:00
|
|
|
# we only this file to release a nix package, use flake.nix for development
|
2021-10-30 15:44:17 +03:00
|
|
|
let
|
2022-07-26 18:21:51 +03:00
|
|
|
rev = "f6342b8b9e7a4177c7e775cdbf38e1c1b43e7ab3"; # nixpkgs master
|
|
|
|
nixpkgs = builtins.fetchTarball {
|
|
|
|
url = "https://github.com/nixos/nixpkgs/tarball/${rev}";
|
|
|
|
sha256 = "JTiKsBT1BwMbtSUsvtSl8ffkiirby8FaujJVGV766Q8=";
|
|
|
|
};
|
|
|
|
pkgs = import nixpkgs { };
|
2021-10-30 15:44:17 +03:00
|
|
|
rustPlatform = pkgs.rustPlatform;
|
2022-07-26 18:21:51 +03:00
|
|
|
llvmPkgs = pkgs.llvmPackages_13;
|
2022-08-01 19:54:16 +03:00
|
|
|
# nix does not store libs in /usr/lib or /lib
|
|
|
|
nixGlibcPath = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
|
2021-10-30 15:44:17 +03:00
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage {
|
|
|
|
pname = "roc";
|
2022-07-26 18:21:51 +03:00
|
|
|
version = "0.0.1";
|
2021-10-30 15:44:17 +03:00
|
|
|
|
|
|
|
src = pkgs.nix-gitignore.gitignoreSource [] ./.;
|
|
|
|
|
2022-08-05 14:31:52 +03:00
|
|
|
cargoSha256 = "sha256-Pd84GGtW1ecrP03uiCVcybIUtWCSDGfLl+fbbdmFyiE=";
|
2021-10-30 15:44:17 +03:00
|
|
|
|
2022-07-26 18:21:51 +03:00
|
|
|
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
|
2021-10-30 15:44:17 +03:00
|
|
|
|
2022-07-26 18:21:51 +03:00
|
|
|
# required for zig
|
2022-07-27 15:35:39 +03:00
|
|
|
XDG_CACHE_HOME = "xdg_cache"; # prevents zig AccessDenied error github.com/ziglang/zig/issues/6810
|
2022-07-26 18:21:51 +03:00
|
|
|
# want to see backtrace in case of failure
|
|
|
|
RUST_BACKTRACE = 1;
|
2021-10-30 15:44:17 +03:00
|
|
|
|
2022-07-27 15:35:39 +03:00
|
|
|
# skip running rust tests, problems:
|
|
|
|
# building of example platforms requires network: Could not resolve host
|
|
|
|
# zig AccessDenied error github.com/ziglang/zig/issues/6810
|
|
|
|
# Once instance has previously been poisoned ??
|
|
|
|
doCheck = false;
|
|
|
|
|
2021-10-30 15:44:17 +03:00
|
|
|
nativeBuildInputs = (with pkgs; [
|
|
|
|
cmake
|
|
|
|
git
|
|
|
|
pkg-config
|
|
|
|
python3
|
|
|
|
llvmPkgs.clang
|
|
|
|
llvmPkgs.llvm.dev
|
2022-07-26 18:21:51 +03:00
|
|
|
zig
|
|
|
|
rust-bindgen
|
2021-10-30 15:44:17 +03:00
|
|
|
]);
|
|
|
|
|
|
|
|
buildInputs = (with pkgs; [
|
|
|
|
libffi
|
|
|
|
libiconv
|
|
|
|
libxkbcommon
|
|
|
|
libxml2
|
|
|
|
ncurses
|
|
|
|
zlib
|
2022-07-26 18:21:51 +03:00
|
|
|
cargo
|
2022-08-01 17:50:38 +03:00
|
|
|
makeWrapper # necessary for postBuild wrapProgram
|
2021-10-30 15:44:17 +03:00
|
|
|
]
|
|
|
|
++ lib.optionals pkgs.stdenv.isLinux [
|
|
|
|
alsa-lib
|
|
|
|
valgrind
|
|
|
|
vulkan-headers
|
|
|
|
vulkan-loader
|
|
|
|
vulkan-tools
|
|
|
|
vulkan-validation-layers
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libXcursor
|
|
|
|
xorg.libXi
|
|
|
|
xorg.libXrandr
|
|
|
|
xorg.libxcb
|
|
|
|
]
|
|
|
|
++ lib.optionals pkgs.stdenv.isDarwin [
|
|
|
|
AppKit
|
|
|
|
CoreFoundation
|
|
|
|
CoreServices
|
|
|
|
CoreVideo
|
|
|
|
Foundation
|
|
|
|
Metal
|
|
|
|
Security
|
|
|
|
]);
|
|
|
|
|
2022-08-01 17:50:38 +03:00
|
|
|
# cp: to copy str.zig,list.zig...
|
|
|
|
# wrapProgram pkgs.stdenv.cc: to make ld available for compiler/build/src/link.rs
|
2022-08-05 14:31:52 +03:00
|
|
|
postInstall = if pkgs.stdenv.isLinux then ''
|
2022-08-01 17:50:38 +03:00
|
|
|
cp -r target/x86_64-unknown-linux-gnu/release/lib/. $out/lib
|
2022-08-01 19:54:16 +03:00
|
|
|
wrapProgram $out/bin/roc --set NIX_GLIBC_PATH ${nixGlibcPath} --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]}
|
2022-08-05 14:31:52 +03:00
|
|
|
'' else ''
|
|
|
|
cp -r target/aarch64-apple-darwin/release/lib/. $out/lib
|
|
|
|
wrapProgram $out/bin/roc --prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.stdenv.cc ]}
|
2022-08-01 17:50:38 +03:00
|
|
|
'';
|
2021-10-30 15:44:17 +03:00
|
|
|
}
|