summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix34
1 files changed, 29 insertions, 5 deletions
diff --git a/flake.nix b/flake.nix
index 020ef53..8c317d4 100644
--- a/flake.nix
+++ b/flake.nix
@@ -8,17 +8,41 @@
   outputs = { self, nixpkgs }: 
   let
     system = "x86_64-darwin";
-    pkgs = import nixpkgs { inherit system; };
+    pkgs = nixpkgs.legacyPackages.${system};
   in {
     packages = { 
-      ${system}.default = pkgs.callPackage ./. {};
+      ${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 glfw glew
-        ];
+        buildInputs = (with pkgs; [
+          pkg-config cmake meson lld
+        ]) ++ (with self.packages.${system}; [
+          glfw-static glew-static
+        ]) ++ (with pkgs.darwin.apple_sdk.frameworks; [
+          Cocoa OpenGL
+        ]);
       };
     };
   };