summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-04-14 22:42:57 +0200
committerMel <einebeere@gmail.com>2024-04-14 22:42:57 +0200
commit0b2474a476b8d54967c7362c2d6bdfc76af1f05b (patch)
tree08c1e81e36c50e5bf3240876fa345ae9eddfe21e /flake.nix
parent659c8b58e5307baad98f52199372a8b0261b4106 (diff)
downloadmeowcraft-0b2474a476b8d54967c7362c2d6bdfc76af1f05b.tar.zst
meowcraft-0b2474a476b8d54967c7362c2d6bdfc76af1f05b.zip
Nix build on x86_64-linux (not static yet)
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix70
1 files changed, 41 insertions, 29 deletions
diff --git a/flake.nix b/flake.nix
index 8c317d4..2124904 100644
--- a/flake.nix
+++ b/flake.nix
@@ -7,43 +7,55 @@
 
   outputs = { self, nixpkgs }: 
   let
-    system = "x86_64-darwin";
-    pkgs = nixpkgs.legacyPackages.${system};
+    allSystems = [ "x86_64-linux" "x86_64-darwin" ];
+
+    pkgsForSystem = system: nixpkgs.legacyPackages.${system};
+
+    forAllSystems = f: nixpkgs.lib.genAttrs allSystems
+      (system: f { inherit system; pkgs = pkgsForSystem 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" ];
-        };
+    packages = forAllSystems ({ system, pkgs }: {  
+      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 = forAllSystems ({ system, pkgs }: 
+    let
+      inherit (pkgs) lib stdenv;
 
-    devShells = {
-      ${system}.default = pkgs.mkShell {
+      darwinFrameworks = pkgs.darwin.apple_sdk.frameworks;
+    in
+    { 
+      default = pkgs.mkShell {
         buildInputs = (with pkgs; [
-          pkg-config cmake meson lld
+          pkg-config ninja cmake meson lldb
         ]) ++ (with self.packages.${system}; [
           glfw-static glew-static
-        ]) ++ (with pkgs.darwin.apple_sdk.frameworks; [
+        ]) ++ lib.optionals stdenv.isDarwin (with darwinFrameworks; [
           Cocoa OpenGL
+        ]) ++ lib.optionals stdenv.isLinux (with pkgs.xorg; [
+          libX11 libXau libXdmcp
         ]);
       };
-    };
+    });
   };
 }