summary refs log tree commit diff
path: root/flake.nix
blob: 8c317d4be0b74a98c994b08f1c42b28c121fefdc (plain)
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
{
  description = "a dumb minecraft in c++ and opengl.";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-23.11";
  };

  outputs = { self, nixpkgs }: 
  let
    system = "x86_64-darwin";
    pkgs = nixpkgs.legacyPackages.${system};
  in {
    packages = { 
      ${system} = { 
        default = pkgs.callPackage ./. {
          inherit (pkgs.darwin.apple_sdk.frameworks)
            Cocoa OpenGL;
          glfw = self.packages.${system}.glfw-static;
          glew = self.packages.${system}.glew-static;
        };

        # NOTE: GLFW depends on OpenSSL and coreutils, which are very
        # large dependencies and have to be rebuilt from source to be able
        # to be linked statically. Maybe there is a way to avoid this?
        glfw-static =  pkgs.glfw.overrideAttrs {
          pname = "glfw-static";
          cmakeFlags = [ "-DBUILD_SHARED_LIBS=OFF" ];
        };

        glew-static =  pkgs.glew.overrideAttrs {
          pname = "glew-static";
          cmakeFlags = [ "-DBUILD_SHARED_LIBS=OFF" ];
        };
      };
    };

    devShells = {
      ${system}.default = pkgs.mkShell {
        buildInputs = (with pkgs; [
          pkg-config cmake meson lld
        ]) ++ (with self.packages.${system}; [
          glfw-static glew-static
        ]) ++ (with pkgs.darwin.apple_sdk.frameworks; [
          Cocoa OpenGL
        ]);
      };
    };
  };
}