-
Notifications
You must be signed in to change notification settings - Fork 14
/
flake.nix
79 lines (76 loc) · 2.83 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
{
inputs = {
nixpkgs.url = "nixpkgs";
};
outputs = { self, nixpkgs, ... }@inputs:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems' = nixpkgs.lib.genAttrs;
forAllSystems = forAllSystems' supportedSystems;
raylibRev = "2a0963ce0936abe0cd3ec32882638d860e435d16";
raylibHash = "sha256-4p3nq04irS8AFojH88Bh1r8KiOjQhZf7nFmQhf1EDU8=";
rayguiRev = "1e03efca48c50c5ea4b4a053d5bf04bad58d3e43";
rayguiHash = "sha256-PzQZxCz63EPd7sVFBYY0T1s9jA5kOAxF9K4ojRoIMz4=";
pkgsForSystem =
system:
import nixpkgs {
inherit system;
overlays = [
(self: super: {
raylib = super.raylib.overrideAttrs (old: {
patches = [];
version = "5.0.0";
src = self.fetchFromGitHub {
owner = "raysan5";
repo = "raylib";
rev = raylibRev;
sha256 = raylibHash;
};
postFixup = "cp ../src/*.h $out/include/";
});
raygui = super.stdenv.mkDerivation { # A bit of a hack to get raygui working
name = "raygui";
version = "4.1.0";
src = self.fetchFromGitHub {
owner = "raysan5";
repo = "raygui";
rev = rayguiRev;
sha256 = rayguiHash;
};
nativeBuildInputs = [];
postFixup = "mkdir -p $out/include/ && cp ./src/raygui.h $out/include/ && cp ./styles/**/*.h $out/include/";
};
})
];
};
depsForSystem =
system:
pkgs:
with pkgs; (
[raylib raygui]
++ lib.optionals stdenv.isLinux (with xorg; [libGL libX11 libXcursor libXext libXi libXinerama libXrandr])
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [OpenGL Cocoa IOKit CoreVideo CoreAudio CoreFoundation])
);
in
{
devShells = forAllSystems (system:
let
pkgs = pkgsForSystem system;
in
{
default =
pkgs.mkShell rec {
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
buildInputs = (with pkgs; [stdenv.cc ghc glfw cabal-install]) ++ depsForSystem system pkgs;
};
}
);
packages = forAllSystems (system: let
pkgs = pkgsForSystem system;
baseInputs = pkgs // pkgs.xorg // pkgs.haskellPackages // rec { systemDeps = depsForSystem system pkgs; buildExamples = false; };
in {
default = import ./default.nix baseInputs;
examples = import ./default.nix (baseInputs // rec { buildExamples = true; });
});
};
}