flake.nix 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (C) by Claudio Cambra <claudio.cambra@nextcloud.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. {
  15. description = "A flake for the Nextcloud desktop client";
  16. inputs = {
  17. nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  18. flake-utils.url = "github:numtide/flake-utils";
  19. };
  20. outputs = { self, nixpkgs, flake-utils }:
  21. with flake-utils.lib;
  22. eachSystem [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ] (system:
  23. let
  24. pkgs = import nixpkgs {
  25. inherit system;
  26. };
  27. inherit (pkgs.lib.lists) optional optionals;
  28. inherit (pkgs.lib.strings) hasPrefix optionalString;
  29. isARM = hasPrefix "aarch64" system;
  30. buildMacOSSymlinks = pkgs.runCommand "nextcloud-build-symlinks" {} ''
  31. mkdir -p $out/bin
  32. ln -s /usr/bin/xcrun /usr/bin/xcodebuild /usr/bin/iconutil $out/bin
  33. '';
  34. nativeBuildInputs = with pkgs; [
  35. cmake
  36. extra-cmake-modules
  37. pkg-config
  38. inkscape
  39. qt5.wrapQtAppsHook
  40. ] ++ optionals stdenv.isDarwin [
  41. buildMacOSSymlinks
  42. ];
  43. buildInputs = with pkgs; [
  44. sqlite
  45. openssl
  46. pcre
  47. qt5.qtbase
  48. qt5.qtquickcontrols2
  49. qt5.qtsvg
  50. qt5.qtgraphicaleffects
  51. qt5.qtdeclarative
  52. qt5.qttools
  53. qt5.qtwebsockets
  54. libsForQt5.karchive
  55. libsForQt5.qtkeychain
  56. ] ++ optionals (!isARM) [
  57. # Qt WebEngine not available on ARM
  58. qt5.qtwebengine
  59. ] ++ optionals stdenv.isLinux [
  60. inotify-tools
  61. libcloudproviders
  62. libsecret
  63. libsForQt5.breeze-icons
  64. libsForQt5.qqc2-desktop-style
  65. libsForQt5.kio
  66. ] ++ optionals stdenv.isDarwin [
  67. libsForQt5.qt5.qtmacextras
  68. darwin.apple_sdk.frameworks.UserNotifications
  69. ];
  70. packages.default = with pkgs; stdenv.mkDerivation rec {
  71. inherit nativeBuildInputs buildInputs;
  72. pname = "nextcloud-client";
  73. version = "dev";
  74. src = ../../.;
  75. dontStrip = true;
  76. enableDebugging = true;
  77. separateDebugInfo = false;
  78. enableParallelBuilding = true;
  79. preConfigure = optionals stdenv.isLinux [
  80. ''
  81. substituteInPlace shell_integration/libcloudproviders/CMakeLists.txt \
  82. --replace "PKGCONFIG_GETVAR(dbus-1 session_bus_services_dir _install_dir)" "set(_install_dir "\$\{CMAKE_INSTALL_DATADIR\}/dbus-1/service")"
  83. ''
  84. ] ++ optionals stdenv.isDarwin [
  85. ''
  86. substituteInPlace shell_integration/MacOSX/CMakeLists.txt \
  87. --replace "-target FinderSyncExt -configuration Release" "-scheme FinderSyncExt -configuration Release -derivedDataPath $ENV{NIX_BUILD_TOP}/derivedData"
  88. ''
  89. ];
  90. cmakeFlags = optionals stdenv.isLinux [
  91. "-DCMAKE_INSTALL_LIBDIR=lib" # expected to be prefix-relative by build code setting RPATH
  92. "-DNO_SHIBBOLETH=1" # allows to compile without qtwebkit
  93. ] ++ optionals stdenv.isDarwin [
  94. "-DQT_ENABLE_VERBOSE_DEPLOYMENT=TRUE"
  95. "-DBUILD_OWNCLOUD_OSX_BUNDLE=OFF"
  96. ];
  97. postPatch = optionalString stdenv.isLinux ''
  98. for file in src/libsync/vfs/*/CMakeLists.txt; do
  99. substituteInPlace $file \
  100. --replace "PLUGINDIR" "KDE_INSTALL_PLUGINDIR"
  101. done
  102. '';
  103. postFixup = optionalString stdenv.isLinux ''
  104. wrapProgram "$out/bin/nextcloud" \
  105. --set LD_LIBRARY_PATH ${lib.makeLibraryPath [ libsecret ]} \
  106. --set PATH ${lib.makeBinPath [ xdg-utils ]} \
  107. --set QML_DISABLE_DISK_CACHE "1"
  108. '';
  109. };
  110. apps.default = mkApp {
  111. name = "nextcloud";
  112. drv = packages.default;
  113. };
  114. in {
  115. inherit packages apps;
  116. devShell = pkgs.mkShell {
  117. inherit buildInputs;
  118. nativeBuildInputs = with pkgs; nativeBuildInputs ++ optionals (stdenv.isLinux) [
  119. gdb
  120. qtcreator
  121. ];
  122. name = "nextcloud-client-dev-shell";
  123. };
  124. }
  125. );
  126. }