diff --git a/modules/common/development/default.nix b/modules/common/development/default.nix index 55620bf2ae..8a3c789aeb 100644 --- a/modules/common/development/default.nix +++ b/modules/common/development/default.nix @@ -4,6 +4,7 @@ imports = [ ./debug-tools.nix ./usb-serial.nix + ./java.nix ./nix.nix ./ssh.nix ]; diff --git a/modules/common/development/java.nix b/modules/common/development/java.nix new file mode 100644 index 0000000000..5f823c16f9 --- /dev/null +++ b/modules/common/development/java.nix @@ -0,0 +1,22 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.ghaf.development.java; +in + with lib; { + options.ghaf.development.java = { + enable = mkEnableOption "Java Support"; + }; + + config = mkIf cfg.enable { + programs.java = { + enable = true; + package = pkgs.jdk20; + }; + }; + } diff --git a/modules/common/profiles/debug.nix b/modules/common/profiles/debug.nix index f17fd98303..0f54f757d7 100644 --- a/modules/common/profiles/debug.nix +++ b/modules/common/profiles/debug.nix @@ -24,6 +24,8 @@ in debug.tools.enable = true; # Let us in. ssh.daemon.enable = true; + # Enable Java + java.enable = true; }; }; }; diff --git a/overlays/custom-packages/default.nix b/overlays/custom-packages/default.nix index 2d4f39484d..d35fef7254 100644 --- a/overlays/custom-packages/default.nix +++ b/overlays/custom-packages/default.nix @@ -6,6 +6,7 @@ # (final: prev: { gala-app = final.callPackage ../../packages/gala {}; + jdk20 = import ./jdk20 {inherit final prev;}; systemd = import ./systemd {inherit final prev;}; waypipe = import ./waypipe {inherit final prev;}; weston = import ./weston {inherit final prev;}; diff --git a/overlays/custom-packages/jdk20/GTK_fix.patch b/overlays/custom-packages/jdk20/GTK_fix.patch new file mode 100644 index 0000000000..522f0c4ea4 --- /dev/null +++ b/overlays/custom-packages/jdk20/GTK_fix.patch @@ -0,0 +1,54 @@ +diff --git a/src/java.desktop/unix/native/libawt_wlawt/WLToolkit.c b/src/java.desktop/unix/native/libawt_wlawt/WLToolkit.c +index 2f46d1354c5..d912f524942 100644 +--- a/src/java.desktop/unix/native/libawt_wlawt/WLToolkit.c ++++ b/src/java.desktop/unix/native/libawt_wlawt/WLToolkit.c +@@ -794,28 +794,29 @@ initCursors() { + int theme_size = 0; + char buffer[256]; + +- char *size_str = getenv("XCURSOR_SIZE"); +- if (!size_str) +- size_str = readDesktopProperty("cursor-size", buffer, sizeof(buffer)); +- if (size_str) +- theme_size = atoi(size_str); +- if (theme_size <= 0) ++ // char *size_str = getenv("XCURSOR_SIZE"); ++ // if (!size_str) ++ // size_str = readDesktopProperty("cursor-size", buffer, sizeof(buffer)); ++ // if (size_str) ++ // theme_size = atoi(size_str); ++ // if (theme_size <= 0) + theme_size = 24; + +- theme_name = getenv("XCURSOR_THEME"); +- if (!theme_name) { +- theme_name = readDesktopProperty("cursor-theme", buffer, sizeof(buffer)); +- if (theme_name) { +- // drop surrounding quotes and trailing line break +- int len = strlen(theme_name); +- if (len > 2) { +- theme_name[len - 2] = 0; +- theme_name++; +- } else { +- theme_name = NULL; +- } +- } +- } ++ // theme_name = getenv("XCURSOR_THEME"); ++ // if (!theme_name) { ++ // theme_name = readDesktopProperty("cursor-theme", buffer, sizeof(buffer)); ++ // if (theme_name) { ++ // // drop surrounding quotes and trailing line break ++ // int len = strlen(theme_name); ++ // if (len > 2) { ++ // theme_name[len - 2] = 0; ++ // theme_name++; ++ // } else { ++ // theme_name = NULL; ++ // } ++ // } ++ // } ++ theme_name="YARU"; + + wl_cursor_theme = wl_cursor_theme_load(theme_name, theme_size, wl_shm); + if (!wl_cursor_theme) { diff --git a/overlays/custom-packages/jdk20/default.nix b/overlays/custom-packages/jdk20/default.nix new file mode 100644 index 0000000000..dfb5bfe3ea --- /dev/null +++ b/overlays/custom-packages/jdk20/default.nix @@ -0,0 +1,67 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +# { +# final, +# prev, +# }: +# # OpenJDK Pure Wayland version +# prev.jdk21.overrideAttrs (_prevAttrs: { +# src = final.pkgs.fetchFromGitHub { +# owner = "openjdk"; +# repo = "wakefield"; +# rev = "pure_wl_toolkit_21"; +# sha256 = "sha256-xmAqj0BLUhLl51AtWshJ8actpk35Gog4PnYqRCa/4RM="; +# }; +# #imports = [../../../packages/libwakefield]; +# #buildInputs = [ libwakefield]; +# #patches = [./GTK_fix.patch]; +# # To fix the direct call for gsettings bug. But there is still problem since there is no GTK schemas installed +# #postConfigure = '' +# # substituteInPlace src/java.desktop/unix/native/libawt_wlawt/WLToolkit.c --replace 'gsettings' '${prev.glib}/bin/gsettings' +# # ''; +# }) +{ + final, + prev, +}: +# OpenJDK Pure Wayland version +prev.jdk20.overrideAttrs (_prevAttrs: { + src = final.pkgs.fetchFromGitHub { + owner = "openjdk"; + repo = "wakefield"; + rev = "pure_wl_toolkit"; + hash = "sha256-TNaRRFqdVevD6tVIz2tBRmKuyNeRc+DXonnKG9adlto="; + }; + imports = [../../../packages/libwakefield]; + libwakefield = final.callPackage ../../../packages/libwakefield {}; + #buildInputs = [libwakefield]; + #patches = [./GTK_fix.patch]; + + #hardeningDisable = [ "all" ]; + #hardeningDisable = _prevAttrs.hardeningDisable or ["all"]; + #NIX_CFLAGS_COMPILE = ( _prevAttrs.NIX_CFLAGS_COMPILE or [ "-g" "-O0" "-Wall" "-" ] ); + + #To fix the direct call for gsettings bug. But there is still problem since there is no GTK schemas installed + postConfigure = '' + substituteInPlace make/common/JavaCompilation.gmk --replace "-Werror" "" + substituteInPlace make/Hsdis.gmk --replace "-Werror" "" + substituteInPlace make/langtools/build.properties --replace "-Werror" "" + #substituteInPlace make/autoconf/flags-cflags.m4 --replace "-Werror" "-Wnoerror" + + #substituteInPlace src/java.base/share/man/java.1 --replace "-Werror" "" + #substituteInPlace src/java.base/share/native/libjli/args.c --replace "-Werror" "" + #substituteInPlace src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java --replace "-Werror" "" + #substituteInPlace src/jdk.javadoc/share/man/javadoc.1 --replace "-Werror" "" + ''; + + installPhase = + '' + pwd; + echo "The build directory is: " . "and the contents are:" ; + ls -l + ls -la build + echo "The out directory is: " $out "and the contents are:"; + ls -l + '' + + _prevAttrs.installPhase; +}) diff --git a/packages/libwakefield/default.nix b/packages/libwakefield/default.nix new file mode 100644 index 0000000000..bc4ca27138 --- /dev/null +++ b/packages/libwakefield/default.nix @@ -0,0 +1,100 @@ +# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors +# SPDX-License-Identifier: Apache-2.0 +{ + fetchFromGitHub, + lib, + cmake, + pkg-config, + stdenv, + gcc, + pixman, + weston, + wayland, + wayland-scanner, + libxkbcommon +}: +let major-version-weston = "libweston-"+builtins.elemAt(builtins.splitVersion (weston.version)) 0; +in stdenv.mkDerivation { + name = "libwakefield"; + + depsBuildBuild = [cmake weston pixman wayland-scanner]; + + src = "${fetchFromGitHub { + owner = "openjdk"; + repo = "wakefield"; + rev = "pure_wl_toolkit_21"; + sha256 = "sha256-xmAqj0BLUhLl51AtWshJ8actpk35Gog4PnYqRCa/4RM="; + }}/src/java.desktop/share/native/libwakefield"; + + nativeBuildInputs = [ + cmake + gcc + pkg-config + weston + pixman + ]; + + buildInputs = [ + wayland + weston + pixman + libxkbcommon + ]; + + #cmakeFlags = lib.optionals (!stdenv.hostPlatform.isStatic) [ + # "-DBUILD_SHARED_LIBS=ON" + #]; + + + configurePhase = '' + substituteInPlace ./CMakeLists.txt --replace "libweston-9" "${major-version-weston}" + substituteInPlace ./CMakeLists.txt --replace "pixman.h + /usr/include /usr/local/include" "pixman.h + ${pixman.outPath}/include" +# substituteInPlace ./CMakeLists.txt --replace "message(FATAL_ERROR \"pixman.h not found\") +#endif ()" "set(PIXMAN_INCLUDES=${pixman.outPath}/include) +#endif () +#set(PIXMAN_INCLUDES=${pixman.outPath}/include)" + + echo "-------------------------CMakeList----------------------------------------------------" + cat ./CMakeLists.txt + echo "--------------------------------------------------------------------------------------" + #find / -name pixman.h + #find /nix/store -name pixman + #find /usr/include -name pixman + #find /include -name pixman + mkdir build && cd build + cmake ../ + substituteInPlace CMakeFiles/wakefield.dir/flags.make --replace "-I/build/libwakefield/build" "-I${pixman.outPath}/include -I/build/libwakefield/build" + echo "--------------------------Pixman Version-----------------------------------------------" + echo "${pixman.version}" + echo "--------------------------MakeFile----------------------------------------------------" + cat Makefile + echo "--------------------------------------------------------------------------------------" + echo "--------------------------flags.make----------------------------------------------------" + cat CMakeFiles/wakefield.dir/flags.make + echo "--------------------------------------------------------------------------------------" + + ''; + + buildPhase = '' + make + ''; + + installPhase = '' + #make install + ''; + + CFLAGS = ["-O3" "-funroll-loops"]; + CXXFLAGS = ["-O3"]; + + outputs = ["bin" "dev" "out"]; + + meta = with lib; { + description = "libwakefield"; + platforms = [ + "aarch64-linux" + "x86_64-linux" + ]; + }; +}