-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
executable file
·106 lines (101 loc) · 3.48 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{
description = "Sursface, a cross-platform rendering library";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
tomers = {
url = "github:boralg/tomers";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, tomers, ... }:
tomers.inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
targetPlatforms =
let
buildFilePatterns = [ ".*/assets/.*" ];
toolchainPackages =
fenixPkgs: crossFenixPkgs: with fenixPkgs; [
latest.rustfmt
stable.rust-src
];
in
[
{
system = "x86_64-unknown-linux-gnu";
arch = "x86_64-linux";
depsBuild = with pkgs; [
patchelf
];
postInstall = crateName: ''
find $out -type f -exec sh -c '
if file "$1" | grep -q "ELF .* executable"; then
patchelf --set-interpreter "/lib64/ld-linux-x86-64.so.2" "$1"
fi
' sh {} \;
'';
inherit buildFilePatterns;
inherit toolchainPackages;
env = {
LD_LIBRARY_PATH =
with pkgs;
lib.makeLibraryPath [
libxkbcommon
wayland
xorg.libX11
xorg.libXrandr
xorg.libXrender
xorg.libXcursor
xorg.libxcb
xorg.libXi
libGL
vulkan-loader
];
};
}
{
system = "x86_64-pc-windows-gnu";
arch = "x86_64-windows";
depsBuild = with pkgs.pkgsCross; [
mingwW64.stdenv.cc
mingwW64.windows.pthreads
];
inherit buildFilePatterns;
inherit toolchainPackages;
env = {
# fixes issues related to libring
TARGET_CC = with pkgs.pkgsCross; "${mingwW64.stdenv.cc}/bin/${mingwW64.stdenv.cc.targetPrefix}cc";
#fixes issues related to openssl
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
};
}
{
system = "wasm32-unknown-unknown";
arch = "wasm32-unknown";
depsBuild = with pkgs; [ wasm-bindgen-cli ];
postInstall = crateName: ''
mkdir $out/bindgen
find $out/bin -type f -name "*.wasm" -exec wasm-bindgen {} --out-dir $out/bindgen --web \;
find $out/lib -type f -name "*.wasm" -exec wasm-bindgen {} --out-dir $out/bindgen --web \;
'';
inherit buildFilePatterns;
inherit toolchainPackages;
env = {
packages = with pkgs; [ wasm-bindgen-cli ];
};
}
];
tomersLib = tomers.libFor system targetPlatforms;
in
rec {
packagesForEachPlatform = tomersLib.packagesForEachPlatform;
devShellsForEachPlatform = tomersLib.devShellsForEachPlatform;
packages = packagesForEachPlatform ./.;
devShells = devShellsForEachPlatform ./.;
}
);
}