all: add support for macOS to flake.nix

The Nix version of the macOS toolchain has difficulties compiling
Objective-C modules; disable modules instead of figuring out why.
It also doesn't include any frameworks automatically; add them explicitly.

While here, move suppression of OpenGL deprecation to a GL-specific
file.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-08-01 01:33:21 +02:00
parent f7bc744a24
commit 5326ca5fbe
12 changed files with 51 additions and 69 deletions
+3
View File
@@ -16,6 +16,9 @@ import (
)
/*
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -xobjective-c -fobjc-arc
#cgo LDFLAGS: -framework OpenGL
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <AppKit/AppKit.h>
+1 -2
View File
@@ -2,8 +2,7 @@
// +build darwin,!ios,nometal
@import AppKit;
#import <AppKit/AppKit.h>
#include <CoreFoundation/CoreFoundation.h>
#include <OpenGL/OpenGL.h>
#include "_cgo_export.h"
+4 -3
View File
@@ -12,10 +12,11 @@ import (
)
/*
#cgo CFLAGS: -Werror -xobjective-c -fmodules -fobjc-arc
#cgo CFLAGS: -Werror -xobjective-c -fobjc-arc
#cgo LDFLAGS: -framework QuartzCore -framework Metal
@import Metal;
@import QuartzCore.CAMetalLayer;
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
#include <CoreFoundation/CoreFoundation.h>
+3 -5
View File
@@ -6,12 +6,10 @@
package app
/*
#cgo CFLAGS: -Werror -xobjective-c -fmodules -fobjc-arc
@import AppKit;
@import QuartzCore.CAMetalLayer;
#cgo CFLAGS: -Werror -xobjective-c -fobjc-arc
#import <AppKit/AppKit.h>
#import <QuartzCore/CAMetalLayer.h>
#include <CoreFoundation/CoreFoundation.h>
CALayer *gio_layerFactory(void) {
+2 -2
View File
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Unlicense OR MIT
@import Dispatch;
@import Foundation;
#import <Dispatch/Dispatch.h>
#import <Foundation/Foundation.h>
#include "_cgo_export.h"
+2 -1
View File
@@ -24,7 +24,8 @@ import (
)
/*
#cgo CFLAGS: -DGL_SILENCE_DEPRECATION -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
#cgo CFLAGS: -Werror -Wno-deprecated-declarations -fobjc-arc -x objective-c
#cgo LDFLAGS: -framework AppKit -framework QuartzCore
#include <AppKit/AppKit.h>
+1 -1
View File
@@ -2,7 +2,7 @@
// +build darwin,!ios
@import AppKit;
#import <AppKit/AppKit.h>
#include "_cgo_export.h"
Generated
+22 -47
View File
@@ -3,17 +3,17 @@
"android": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils_2",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1654115078,
"narHash": "sha256-V1XCuFIl6QJuCSJvWKWZKzoHZ+oXP2jYEev4Wf49qk4=",
"lastModified": 1659298920,
"narHash": "sha256-LgRMge8BZUG15EN43iDJOlnEMX1dvRprB7SaoNqgibU=",
"owner": "tadfisher",
"repo": "android-nixpkgs",
"rev": "5573d91ad076bfceeae780d9942ab6ec4ef000f0",
"rev": "d4f20a3cd4ce961bb23b48447457f6810d69ae5e",
"type": "github"
},
"original": {
@@ -24,15 +24,21 @@
},
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"flake-utils": [
"android",
"nixpkgs"
],
"nixpkgs": [
"android",
"nixpkgs"
]
},
"locked": {
"lastModified": 1653917170,
"narHash": "sha256-FyxOnEE/V4PNEcMU62ikY4FfYPo349MOhMM97HS0XEo=",
"lastModified": 1658746384,
"narHash": "sha256-CCJcoMOcXyZFrV1ag4XMTpAPjLWb4Anbv+ktXFI1ry0=",
"owner": "numtide",
"repo": "devshell",
"rev": "fc7a3e3adde9bbcab68af6d1e3c6eb738e296a92",
"rev": "0ffc7937bb5e8141af03d462b468bd071eb18e1b",
"type": "github"
},
"original": {
@@ -43,26 +49,11 @@
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
@@ -73,27 +64,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"lastModified": 1659305579,
"narHash": "sha256-SFeQTmh7hc9Y2fSkooHaoS8mDfPa04sfmUCtQ8MA6Pg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1654165167,
"narHash": "sha256-cx57sQl9Q+kJoIB0INg8Gomvyl2KahCL9UPz0F6g20Y=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7adf49bbab9814d5b071d50cf17cce4270e1c294",
"rev": "5857574d45925585baffde730369414319228a84",
"type": "github"
},
"original": {
@@ -105,7 +80,7 @@
"root": {
"inputs": {
"android": "android",
"nixpkgs": "nixpkgs_2"
"nixpkgs": "nixpkgs"
}
}
},
+6
View File
@@ -47,6 +47,12 @@
xorg.libXfixes
libGL
pkgconfig
] else if stdenv.isDarwin then [
darwin.apple_sdk_11_0.frameworks.Foundation
darwin.apple_sdk_11_0.frameworks.Metal
darwin.apple_sdk_11_0.frameworks.QuartzCore
darwin.apple_sdk_11_0.frameworks.AppKit
darwin.apple_sdk_11_0.MacOSX-SDK
] else [ ]);
} // (if stdenv.isLinux then {
LD_LIBRARY_PATH = "${vulkan-loader}/lib";
+3 -3
View File
@@ -10,10 +10,10 @@ import (
)
/*
#cgo CFLAGS: -Werror -Wno-deprecated-declarations -fmodules -fobjc-arc -x objective-c
#cgo LDFLAGS: -framework CoreGraphics
#cgo CFLAGS: -Werror -Wno-deprecated-declarations -fobjc-arc -x objective-c
#cgo LDFLAGS: -framework CoreGraphics -framework Metal -framework Foundation
@import Metal;
#import <Metal/Metal.h>
static CFTypeRef createDevice(void) {
@autoreleasepool {
+2 -4
View File
@@ -13,10 +13,8 @@ import (
)
/*
#cgo CFLAGS: -Werror -xobjective-c -fmodules -fobjc-arc
#cgo LDFLAGS: -framework CoreGraphics
@import Metal;
#cgo CFLAGS: -Werror -xobjective-c -fobjc-arc
#cgo LDFLAGS: -framework CoreGraphics -framework Metal -framework Foundation
#include <CoreFoundation/CoreFoundation.h>
#include <Metal/Metal.h>
+2 -1
View File
@@ -5,7 +5,8 @@
package cocoainit
/*
#cgo CFLAGS: -xobjective-c -fmodules -fobjc-arc
#cgo CFLAGS: -xobjective-c -fobjc-arc
#cgo LDFLAGS: -framework Foundation
#import <Foundation/Foundation.h>
static inline void activate_cocoa_multithreading() {