From 3b71d39d2e8685fae87869350bf85d81375a5642 Mon Sep 17 00:00:00 2001 From: Matthieu Daniel-Thomas Date: Wed, 23 Oct 2024 14:55:41 +0200 Subject: [PATCH 1/5] gitignore: update file for vscode --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 27b102b6..ddafb100 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ outputs # Created by running NixOS tests in interactive mode .nixos-test-history + +#VScode extra files +*.code-workspace From e95f6b3aa8081c8a6549f1236362d7e48bab676f Mon Sep 17 00:00:00 2001 From: Matthieu Daniel-Thomas Date: Thu, 7 Nov 2024 09:20:58 +0100 Subject: [PATCH 2/5] phoebus-client: add a wrapper The wrapper was added for edit JAVA_OPTS in options. --- pkgs/default.nix | 3 +- .../phoebus/client-unwrapped/default.nix | 90 +++++++++++ .../fix-python-path.patch | 0 pkgs/epnix/tools/phoebus/client/default.nix | 153 ++++++------------ 4 files changed, 138 insertions(+), 108 deletions(-) create mode 100644 pkgs/epnix/tools/phoebus/client-unwrapped/default.nix rename pkgs/epnix/tools/phoebus/{client => client-unwrapped}/fix-python-path.patch (100%) diff --git a/pkgs/default.nix b/pkgs/default.nix index cf74aebc..a339bcaf 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -94,7 +94,8 @@ in pcas = callPackage ./epnix/tools/pcas {}; - phoebus = callPackage ./epnix/tools/phoebus/client { + phoebus = callPackage ./epnix/tools/phoebus/client {}; + phoebus-unwrapped = callPackage ./epnix/tools/phoebus/client-unwrapped { jdk = prev.jdk21; openjfx = prev.openjfx21; }; diff --git a/pkgs/epnix/tools/phoebus/client-unwrapped/default.nix b/pkgs/epnix/tools/phoebus/client-unwrapped/default.nix new file mode 100644 index 00000000..f600a55d --- /dev/null +++ b/pkgs/epnix/tools/phoebus/client-unwrapped/default.nix @@ -0,0 +1,90 @@ +{ + lib, + epnixLib, + stdenv, + substituteAll, + maven, + makeWrapper, + epnix, + jdk, + openjfx, + python3, +}: let + buildDate = "2022-02-24T07:56:00Z"; +in + stdenv.mkDerivation { + pname = "phoebus-unwrapped"; + inherit (epnix.phoebus-deps) version src; + + patches = [ + (substituteAll { + src = ./fix-python-path.patch; + python = lib.getExe python3; + }) + ]; + + # TODO: make a scope, so that we don't pass around the whole `epnix` + nativeBuildInputs = [ + maven + makeWrapper + (epnix.phoebus-setup-hook.override { + jdk = jdk.override { + enableJavaFX = true; + openjfx_jdk = openjfx.override { + withWebKit = true; + }; + }; + }) + ]; + + # Put runtime dependencies in propagated + # because references get thrown into a jar + # which is compressed, + # so the Nix scanner won't always be able to see them + propagatedBuildInputs = [ + python3 + ]; + + buildPhase = '' + runHook preBuild + + # Copy deps to a writable directory, due to the usage of "install-jars" + local deps=$PWD/deps + cp -r --no-preserve=mode "${epnix.phoebus-deps}" $deps + + # TODO: tests fail + mvn package \ + --projects "./phoebus-product" \ + --also-make \ + --offline \ + -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -DskipTests \ + -Dproject.build.outputTimestamp=${buildDate} \ + -Dmaven.repo.local="$deps" + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + installPhoebusJar \ + "phoebus-product/" \ + "product-$version.jar" \ + "phoebus" \ + "org.phoebus.product.Launcher" + + # MIME types for PV Tables + install -D -m 444 phoebus-product/phoebus.xml -t $out/share/mime/packages + + runHook postInstall + ''; + + meta = { + description = "Control System Studio's Phoebus client"; + homepage = "https://control-system-studio.readthedocs.io/en/latest/index.html"; + mainProgram = "phoebus"; + license = lib.licenses.epl10; + maintainers = with epnixLib.maintainers; [minijackson]; + inherit (jdk.meta) platforms; + }; + } diff --git a/pkgs/epnix/tools/phoebus/client/fix-python-path.patch b/pkgs/epnix/tools/phoebus/client-unwrapped/fix-python-path.patch similarity index 100% rename from pkgs/epnix/tools/phoebus/client/fix-python-path.patch rename to pkgs/epnix/tools/phoebus/client-unwrapped/fix-python-path.patch diff --git a/pkgs/epnix/tools/phoebus/client/default.nix b/pkgs/epnix/tools/phoebus/client/default.nix index c5431d4c..f6c3a831 100644 --- a/pkgs/epnix/tools/phoebus/client/default.nix +++ b/pkgs/epnix/tools/phoebus/client/default.nix @@ -1,111 +1,50 @@ { - lib, - epnixLib, - stdenv, - substituteAll, - maven, makeWrapper, + epnix, + epnixLib, + lib, makeDesktopItem, copyDesktopItems, - epnix, - jdk, - openjfx, - python3, -}: let - buildDate = "2022-02-24T07:56:00Z"; -in - stdenv.mkDerivation { - pname = "phoebus"; - inherit (epnix.phoebus-deps) version src; - - patches = [ - (substituteAll { - src = ./fix-python-path.patch; - python = lib.getExe python3; - }) - ]; - - # TODO: make a scope, so that we don't pass around the whole `epnix` - nativeBuildInputs = [ - maven - copyDesktopItems - makeWrapper - (epnix.phoebus-setup-hook.override { - jdk = jdk.override { - enableJavaFX = true; - openjfx_jdk = openjfx.override { - withWebKit = true; - }; - }; - }) - ]; - - # Put runtime dependencies in propagated - # because references get thrown into a jar - # which is compressed, - # so the Nix scanner won't always be able to see them - propagatedBuildInputs = [ - python3 - ]; - - desktopItems = [ - (makeDesktopItem { - name = "phoebus"; - exec = "phoebus -server 4918 -resource %f"; - desktopName = "Phoebus"; - keywords = ["epics" "css"]; - # https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry - categories = [ - # Main - "Office" - - # Additional - "Java" - "Viewer" - ]; - }) - ]; - - buildPhase = '' - runHook preBuild - - # Copy deps to a writable directory, due to the usage of "install-jars" - local deps=$PWD/deps - cp -r --no-preserve=mode "${epnix.phoebus-deps}" $deps - - # TODO: tests fail - mvn package \ - --projects "./phoebus-product" \ - --also-make \ - --offline \ - -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -DskipTests \ - -Dproject.build.outputTimestamp=${buildDate} \ - -Dmaven.repo.local="$deps" - - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - installPhoebusJar \ - "phoebus-product/" \ - "product-$version.jar" \ - "phoebus" \ - "org.phoebus.product.Launcher" - - # MIME types for PV Tables - install -D -m 444 phoebus-product/phoebus.xml -t $out/share/mime/packages - - runHook postInstall - ''; - - meta = { - description = "Control System Studio's Phoebus client"; - homepage = "https://control-system-studio.readthedocs.io/en/latest/index.html"; - mainProgram = "phoebus"; - license = lib.licenses.epl10; - maintainers = with epnixLib.maintainers; [minijackson]; - inherit (jdk.meta) platforms; - }; - } + stdenv, + # Inspired by: + # https://epics.anl.gov/tech-talk/2024/msg00895.php + java_opts ? "-XX:MinHeapSize=128m -XX:MaxHeapSize=4g -XX:InitialHeapSize=1g -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps -XX:NativeMemoryTracking=detail", +}: +stdenv.mkDerivation { + pname = "phoebus"; + inherit (epnix.phoebus-unwrapped) version; + nativeBuildInputs = [makeWrapper copyDesktopItems]; + + dontUnpack = true; + dontBuild = true; + dontConfigure = true; + + installPhase = '' + runHook preInstall + + # This wrapper for the `phoebus-unwrapped` executable sets the `JAVA_OPTS` + makeWrapper "${lib.getExe epnix.phoebus-unwrapped}" "$out/bin/$pname" \ + --prefix JAVA_OPTS " " "${java_opts}" + + runHook postInstall + ''; + + desktopItems = [ + (makeDesktopItem { + name = "phoebus"; + exec = "phoebus -server 4918 -resource %f"; + desktopName = "Phoebus"; + keywords = ["epics" "css"]; + # https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry + categories = [ + # Main + "Office" + # Additional + "Java" + "Viewer" + ]; + }) + ]; + + inherit (epnix.phoebus-unwrapped) meta; +} From 06bfcbcb38d8199f692b67118ccf6ddb47487cfe Mon Sep 17 00:00:00 2001 From: Matthieu Daniel-Thomas Date: Thu, 7 Nov 2024 09:23:18 +0100 Subject: [PATCH 3/5] nixos/phoebus: add modules Add the possibility to enable phoebus in a nixos configuration Add the possibility to edit java_opts --- nixos/module-list.nix | 1 + nixos/modules/phoebus/client.nix | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 nixos/modules/phoebus/client.nix diff --git a/nixos/module-list.nix b/nixos/module-list.nix index 399e1d06..607ec3de 100644 --- a/nixos/module-list.nix +++ b/nixos/module-list.nix @@ -5,6 +5,7 @@ ./modules/channel-finder/service.nix ./modules/phoebus/alarm-logger.nix ./modules/phoebus/alarm-server.nix + ./modules/phoebus/client.nix ./modules/phoebus/olog.nix ./modules/phoebus/save-and-restore.nix ] diff --git a/nixos/modules/phoebus/client.nix b/nixos/modules/phoebus/client.nix new file mode 100644 index 00000000..be6346c5 --- /dev/null +++ b/nixos/modules/phoebus/client.nix @@ -0,0 +1,28 @@ +{ + config, + lib, + pkgs, + ... +}: let + cfg = config.programs.phoebus-client; + pkg = pkgs.epnix.phoebus.override {java_opts = cfg.java_opts;}; +in { + options.programs.phoebus-client = { + enable = lib.mkEnableOption "installing and configuring the Phoebus client"; + java_opts = lib.mkOption { + type = lib.types.str; + default = "-XX:MinHeapSize=128m -XX:MaxHeapSize=4g -XX:InitialHeapSize=1g -XX:MaxHeapFreeRatio=10 -XX:MinHeapFreeRatio=5 -XX:-ShrinkHeapInSteps -XX:NativeMemoryTracking=detail"; + example = "-XX:MinHeapSize=128m -XX:MaxHeapSize=4g -XX:InitialHeapSize=1g"; + description = '' + Set Java options for the Phoebus client. + + For more information, see: + https://docs.oracle.com/en/java/javase/21/docs/specs/man/java.html#extra-options-for-java + ''; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [pkg]; + }; +} From dc607b24c9828629e4ff3827ecc6d2dd7e85cb5c Mon Sep 17 00:00:00 2001 From: Matthieu Daniel-Thomas Date: Thu, 12 Dec 2024 15:16:19 +0100 Subject: [PATCH 4/5] docs: Documentation for phoebus client options --- docs/nixos-services/options-reference/phoebus-client.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 docs/nixos-services/options-reference/phoebus-client.rst diff --git a/docs/nixos-services/options-reference/phoebus-client.rst b/docs/nixos-services/options-reference/phoebus-client.rst new file mode 100644 index 00000000..c96706f7 --- /dev/null +++ b/docs/nixos-services/options-reference/phoebus-client.rst @@ -0,0 +1,4 @@ +Phoebus Client +============== + +.. nix:automodule:: programs.phoebus-client From 68cb91eb3780740f786704ad99b289743712d81d Mon Sep 17 00:00:00 2001 From: Matthieu Daniel-Thomas Date: Wed, 22 Jan 2025 16:30:54 +0100 Subject: [PATCH 5/5] docs: Add release note for the new options --- docs/release-notes/2411.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/release-notes/2411.rst b/docs/release-notes/2411.rst index a29918d6..b8ebc16f 100644 --- a/docs/release-notes/2411.rst +++ b/docs/release-notes/2411.rst @@ -19,6 +19,12 @@ Breaking changes due to its license. Migrate your data by following :ref:`mongodb-to-ferretdb`. +New features +------------ + +- A new module :nix:option:`programs.phoebus-client` was added + to install Phoebus and set up Java options. + Detailed migration information ------------------------------