Add support for macOS to flake

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
This commit is contained in:
Claudio Cambra 2022-09-29 13:23:50 +02:00
parent 6aee845b29
commit 19a2f8cc7d
3 changed files with 52 additions and 17 deletions

View file

@ -22,29 +22,35 @@
outputs = { self, nixpkgs, flake-utils }: outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; with flake-utils.lib;
eachSystem [ "aarch64-linux" "x86_64-linux" ] (system: eachSystem [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ] (system:
let let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
}; };
inherit (pkgs.lib.lists) optional optionals; inherit (pkgs.lib.lists) optional optionals;
inherit (pkgs.lib.strings) hasPrefix hasSuffix; inherit (pkgs.lib.strings) hasPrefix optionalString;
isMacOS = hasSuffix "darwin" system;
isARM = hasPrefix "aarch64" system; isARM = hasPrefix "aarch64" system;
buildMacOSSymlinks = pkgs.runCommand "nextcloud-build-symlinks" {} ''
mkdir -p $out/bin
ln -s /usr/bin/xcrun /usr/bin/xcodebuild /usr/bin/iconutil $out/bin
'';
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
cmake cmake
extra-cmake-modules extra-cmake-modules
pkg-config pkg-config
inkscape
qt5.wrapQtAppsHook qt5.wrapQtAppsHook
] ++ optionals stdenv.isDarwin [
buildMacOSSymlinks
]; ];
buildInputs = with pkgs; [ buildInputs = with pkgs; [
sqlite sqlite
openssl openssl
pcre pcre
inkscape
qt5.qtbase qt5.qtbase
qt5.qtquickcontrols2 qt5.qtquickcontrols2
@ -59,7 +65,7 @@
] ++ optionals (!isARM) [ ] ++ optionals (!isARM) [
# Qt WebEngine not available on ARM # Qt WebEngine not available on ARM
qt5.qtwebengine qt5.qtwebengine
] ++ optionals (stdenv.isLinux) [ ] ++ optionals stdenv.isLinux [
inotify-tools inotify-tools
libcloudproviders libcloudproviders
libsecret libsecret
@ -67,6 +73,10 @@
libsForQt5.breeze-icons libsForQt5.breeze-icons
libsForQt5.qqc2-desktop-style libsForQt5.qqc2-desktop-style
libsForQt5.kio libsForQt5.kio
] ++ optionals stdenv.isDarwin [
libsForQt5.qt5.qtmacextras
darwin.apple_sdk.frameworks.UserNotifications
]; ];
packages.default = with pkgs; stdenv.mkDerivation rec { packages.default = with pkgs; stdenv.mkDerivation rec {
@ -74,25 +84,43 @@
pname = "nextcloud-client"; pname = "nextcloud-client";
version = "dev"; version = "dev";
src = ../../.; src = ../../.;
dontStrip = true; dontStrip = true;
enableDebugging = true; enableDebugging = true;
separateDebugInfo = false; separateDebugInfo = false;
cmakeFlags = if(stdenv.isLinux) then [ enableParallelBuilding = true;
preConfigure = optionals stdenv.isLinux [
''
substituteInPlace shell_integration/libcloudproviders/CMakeLists.txt \
--replace "PKGCONFIG_GETVAR(dbus-1 session_bus_services_dir _install_dir)" "set(_install_dir "\$\{CMAKE_INSTALL_DATADIR\}/dbus-1/service")"
''
] ++ optionals stdenv.isDarwin [
''
substituteInPlace shell_integration/MacOSX/CMakeLists.txt \
--replace "-target FinderSyncExt -configuration Release" "-scheme FinderSyncExt -configuration Release -derivedDataPath $ENV{NIX_BUILD_TOP}/derivedData"
''
];
cmakeFlags = optionals stdenv.isLinux [
"-DCMAKE_INSTALL_LIBDIR=lib" # expected to be prefix-relative by build code setting RPATH "-DCMAKE_INSTALL_LIBDIR=lib" # expected to be prefix-relative by build code setting RPATH
"-DNO_SHIBBOLETH=1" # allows to compile without qtwebkit "-DNO_SHIBBOLETH=1" # allows to compile without qtwebkit
] else []; ] ++ optionals stdenv.isDarwin [
postPatch = if(stdenv.isLinux) then '' "-DQT_ENABLE_VERBOSE_DEPLOYMENT=TRUE"
"-DBUILD_OWNCLOUD_OSX_BUNDLE=OFF"
];
postPatch = optionalString stdenv.isLinux ''
for file in src/libsync/vfs/*/CMakeLists.txt; do for file in src/libsync/vfs/*/CMakeLists.txt; do
substituteInPlace $file \ substituteInPlace $file \
--replace "PLUGINDIR" "KDE_INSTALL_PLUGINDIR" --replace "PLUGINDIR" "KDE_INSTALL_PLUGINDIR"
done done
'' else ""; '';
postFixup = if(stdenv.isLinux) then '' postFixup = optionalString stdenv.isLinux ''
wrapProgram "$out/bin/nextcloud" \ wrapProgram "$out/bin/nextcloud" \
--set LD_LIBRARY_PATH ${lib.makeLibraryPath [ libsecret ]} \ --set LD_LIBRARY_PATH ${lib.makeLibraryPath [ libsecret ]} \
--set PATH ${lib.makeBinPath [ xdg-utils ]} \ --set PATH ${lib.makeBinPath [ xdg-utils ]} \
--set QML_DISABLE_DISK_CACHE "1" --set QML_DISABLE_DISK_CACHE "1"
'' else ""; '';
}; };
apps.default = mkApp { apps.default = mkApp {
@ -104,7 +132,7 @@
inherit packages apps; inherit packages apps;
devShell = pkgs.mkShell { devShell = pkgs.mkShell {
inherit buildInputs; inherit buildInputs;
nativeBuildInputs = with pkgs; nativeBuildInputs ++[ nativeBuildInputs = with pkgs; nativeBuildInputs ++ optionals (stdenv.isLinux) [
gdb gdb
qtcreator qtcreator
]; ];

View file

@ -33,14 +33,14 @@
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
C2B573E11B1CD9CE00303B36 /* Embed App Extensions */ = { C2B573E11B1CD9CE00303B36 /* Embed App Extensions */ = {
isa = PBXCopyFilesBuildPhase; isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 8;
dstPath = ""; dstPath = "";
dstSubfolderSpec = 13; dstSubfolderSpec = 13;
files = ( files = (
C2B573E21B1CD9CE00303B36 /* FinderSyncExt.appex in Embed App Extensions */, C2B573E21B1CD9CE00303B36 /* FinderSyncExt.appex in Embed App Extensions */,
); );
name = "Embed App Extensions"; name = "Embed App Extensions";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 1;
}; };
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
@ -198,10 +198,12 @@
C2B573B01B1CD91E00303B36 = { C2B573B01B1CD91E00303B36 = {
CreatedOnToolsVersion = 6.3.1; CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 9B5WD74GWJ; DevelopmentTeam = 9B5WD74GWJ;
ProvisioningStyle = Manual;
}; };
C2B573D61B1CD9CE00303B36 = { C2B573D61B1CD9CE00303B36 = {
CreatedOnToolsVersion = 6.3.1; CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 9B5WD74GWJ; DevelopmentTeam = 9B5WD74GWJ;
ProvisioningStyle = Manual;
SystemCapabilities = { SystemCapabilities = {
com.apple.ApplicationGroups.Mac = { com.apple.ApplicationGroups.Mac = {
enabled = 1; enabled = 1;
@ -384,6 +386,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
@ -433,6 +436,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
@ -475,6 +479,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = FinderSyncExt/FinderSyncExt.entitlements; CODE_SIGN_ENTITLEMENTS = FinderSyncExt/FinderSyncExt.entitlements;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
@ -529,7 +534,8 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = FinderSyncExt/FinderSyncExt.entitlements; CODE_SIGN_ENTITLEMENTS = FinderSyncExt/FinderSyncExt.entitlements;
CODE_SIGN_IDENTITY = "-"; CODE_SIGN_IDENTITY = "-";
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";

View file

@ -83,6 +83,7 @@
savedToolIdentifier = "" savedToolIdentifier = ""
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES" debugDocumentVersioning = "YES"
askForAppToLaunch = "Yes"
launchAutomaticallySubstyle = "2"> launchAutomaticallySubstyle = "2">
<BuildableProductRunnable <BuildableProductRunnable
runnableDebuggingMode = "0"> runnableDebuggingMode = "0">