updated default.nix

This commit is contained in:
Anton-4 2022-07-26 17:21:51 +02:00
parent 9a3998a10b
commit 94380f32de
No known key found for this signature in database
GPG Key ID: A13F4A6E21141925
3 changed files with 42 additions and 20 deletions

View File

@ -1,49 +1,70 @@
{ }:
# we only this file to release a nix package, use flake.nix for development
let
sources = import nix/sources.nix { };
pkgs = import sources.nixpkgs { };
rev = "f6342b8b9e7a4177c7e775cdbf38e1c1b43e7ab3"; # nixpkgs master
nixpkgs = builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/tarball/${rev}";
sha256 = "JTiKsBT1BwMbtSUsvtSl8ffkiirby8FaujJVGV766Q8=";
};
pkgs = import nixpkgs { };
rustPlatform = pkgs.rustPlatform;
llvmPkgs = pkgs.llvmPackages_12;
llvmPkgs = pkgs.llvmPackages_13;
in
rustPlatform.buildRustPackage {
pname = "roc";
version = "0.1.0";
version = "0.0.1";
src = pkgs.nix-gitignore.gitignoreSource [] ./.;
cargoSha256 = "11r8drmps92i7l3bg3zabds9n5rim9f4fjsgr86nhqhcsivi80y4";
cargoSha256 = "sha256-oSi9UIom3YowgfR1U4c6her3SsfeV//t6Dy3eOQaW9o=";
LLVM_SYS_120_PREFIX = "${llvmPkgs.llvm.dev}";
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
# required for zig builds
# for cli bindgen "No such file or directory"
preBuild = ''
# From: https://github.com/NixOS/nixpkgs/blob/1fab95f5190d087e66a3502481e34e15d62090aa/pkgs/applications/networking/browsers/firefox/common.nix#L247-L253
# Set C flags for Rust's bindgen program. Unlike ordinary C
# compilation, bindgen does not invoke $CC directly. Instead it
# uses LLVM's libclang. To make sure all necessary flags are
# included we need to look in a few places.
export BINDGEN_EXTRA_CLANG_ARGS="$(< ${pkgs.stdenv.cc}/nix-support/libc-crt1-cflags) \
$(< ${pkgs.stdenv.cc}/nix-support/libc-cflags) \
$(< ${pkgs.stdenv.cc}/nix-support/cc-cflags) \
$(< ${pkgs.stdenv.cc}/nix-support/libcxx-cxxflags) \
${pkgs.lib.optionalString pkgs.stdenv.cc.isClang "-idirafter ${pkgs.stdenv.cc.cc}/lib/clang/${pkgs.lib.getVersion pkgs.stdenv.cc.cc}/include"} \
${pkgs.lib.optionalString pkgs.stdenv.cc.isGNU "-isystem ${pkgs.stdenv.cc.cc}/include/c++/${pkgs.lib.getVersion pkgs.stdenv.cc.cc} -isystem ${pkgs.stdenv.cc.cc}/include/c++/${pkgs.lib.getVersion pkgs.stdenv.cc.cc}/${pkgs.stdenv.hostPlatform.config}"}
"
'';
# required for zig
XDG_CACHE_HOME = "/build/xdgcache";
# nix does not store libs in /usr/lib or /lib
NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
# want to see backtrace in case of failure
RUST_BACKTRACE = 1;
nativeBuildInputs = (with pkgs; [
cmake
git
pkg-config
python3
llvmPkgs.lld
llvmPkgs.clang
llvmPkgs.llvm.dev
(import ./nix/zig.nix { inherit pkgs; })
zig
rust-bindgen
]);
buildInputs = (with pkgs; [
(import ./nix/debugir.nix { inherit pkgs; })
libffi
libiconv
libxkbcommon
libxml2
ncurses
zlib
cargo
]
++ lib.optionals pkgs.stdenv.isLinux [
alsa-lib
glibc_multi
valgrind
vulkan-headers
vulkan-loader

View File

@ -67,16 +67,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1647282937,
"narHash": "sha256-K8Oo6QyFCfiEWTRpQVfzcwI3YNMKlz6Tu8rr+o3rzRQ=",
"lastModified": 1657972522,
"narHash": "sha256-JTiKsBT1BwMbtSUsvtSl8ffkiirby8FaujJVGV766Q8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "64fc73bd74f04d3e10cb4e70e1c65b92337e76db",
"rev": "07a2e6a4e31ea48408861607198972d60adaf4ad",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-21.11",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}

View File

@ -2,7 +2,7 @@
description = "Roc flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-21.11";
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
# rust from nixpkgs has some libc problems, this is patched in the rust-overlay
rust-overlay = {
url = "github:oxalica/rust-overlay";
@ -24,7 +24,7 @@
outputs = { self, nixpkgs, rust-overlay, zig, flake-utils, nixgl }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
in
flake-utils.lib.eachSystem supportedSystems (system:
let
@ -120,6 +120,7 @@
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs ++ (if system == "x86_64-linux" then [ pkgs.nixgl.nixVulkanIntel ] else []);
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
# nix does not store libs in /usr/lib or /lib
NIX_GLIBC_PATH = if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
LD_LIBRARY_PATH = with pkgs;
lib.makeLibraryPath