-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from Rider128/default-option-phoebus
phoebus-setup-hook: add java heap size and change encoding by default for phoebus
- Loading branch information
Showing
9 changed files
with
180 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Phoebus Client | ||
============== | ||
|
||
.. nix:automodule:: programs.phoebus-client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |