diff --git a/pkgs/by-name/ke/keyboard-layout-editor/deps.json b/pkgs/by-name/ke/keyboard-layout-editor/deps.json new file mode 100644 index 0000000000000..3a9c1e2f09ce0 --- /dev/null +++ b/pkgs/by-name/ke/keyboard-layout-editor/deps.json @@ -0,0 +1,112 @@ +{ + "!comment": "This is a nixpkgs Gradle dependency lockfile. For more details, refer to the Gradle section in the nixpkgs manual.", + "!version": 1, + "https://plugins.gradle.org/m2": { + "com/google/code/findbugs#jsr305/3.0.2": { + "jar": "sha256-dmrSoHg/JoeWLIrXTO7MOKKLn3Ki0IXuQ4t4E+ko0Mc=", + "pom": "sha256-GYidvfGyVLJgGl7mRbgUepdGRIgil2hMeYr+XWPXjf4=" + }, + "com/google/gradle#osdetector-gradle-plugin/1.7.3": { + "jar": "sha256-a0aS+ROiGx+2Axae54uo8+SrKvnXYq+cqIt5EmwcCtE=", + "pom": "sha256-hGDJUBJ8o1mHZhYeOLT/jWO01p+4MQoW4As1E1ABDBE=" + }, + "kr/motd/maven#os-maven-plugin/1.7.1": { + "jar": "sha256-9Hru+Ggh5SsrGHWJeL0EXwPXIikuMudHCCEixiKJUuA=", + "pom": "sha256-S3WABEIrljPdMY8p54Tx0YC9ilkgzVCvGTCGH21qVHY=" + }, + "org/openjfx#javafx-plugin/0.1.0": { + "jar": "sha256-Xq7sB5m0QGRrDKTP2iGaMttr4rpXktAyoNpKOlw4j6s=", + "module": "sha256-rf+3RA0kntF8BJOD1nBp+UU7F3gncMAFtoKkNBbYNmE=", + "pom": "sha256-NMjfVSfrWjXl8AmjzeH3oInEzkoOclgC8uy+UDu9PLY=" + }, + "org/openjfx/javafxplugin#org.openjfx.javafxplugin.gradle.plugin/0.1.0": { + "pom": "sha256-1tASf/Q2PQAXPDV6mByec+/wPDCl0Ohq2CtgVPrvqEE=" + }, + "org/sonatype/oss#oss-parent/7": { + "pom": "sha256-tR+IZ8kranIkmVV/w6H96ne9+e9XRyL+kM5DailVlFQ=" + }, + "org/sonatype/oss#oss-parent/9": { + "pom": "sha256-+0AmX5glSCEv+C42LllzKyGH7G8NgBgohcFO8fmCgno=" + } + }, + "https://repo.maven.apache.org/maven2": { + "com/google/code/gson#gson-parent/2.8.5": { + "pom": "sha256-jx/scrkaceo57Dn193jE0RJLawl8bVWzpQtVSlIjeyc=" + }, + "com/google/code/gson#gson/2.8.5": { + "jar": "sha256-IzoBSfw2XJ9u29aDz+JmsZvcdzvpjqva9rPJJLSOfYE=", + "pom": "sha256-uDCFV6f8zJLZ/nyM0FmSWLNhKF0uzedontqYhDJVoJI=" + }, + "commons-io#commons-io/2.6": { + "jar": "sha256-+HfTBGYKwqFC84ZbrfyXHex+1zx0fH+NXS9ROcpzZRM=", + "pom": "sha256-DCOGOJOiKR9aev29jRWSOzlIr9h+Vj+jQc3Pbq4zimA=" + }, + "junit#junit/4.12": { + "jar": "sha256-WXIfCAXiI9hLkGd4h9n/Vn3FNNfFAsqQPAwrF/BcEWo=", + "pom": "sha256-kPFj944/+28cetl96efrpO6iWAcUG4XW0SvmfKJUScQ=" + }, + "org/apache#apache/15": { + "pom": "sha256-NsLy+XmsZ7RQwMtIDk6br2tA86aB8iupaSKH0ROa1JQ=" + }, + "org/apache#apache/18": { + "pom": "sha256-eDEwcoX9R1u8NrIK4454gvEcMVOx1ZMPhS1E7ajzPBc=" + }, + "org/apache#apache/19": { + "pom": "sha256-kfejMJbqabrCy69tAf65NMrAAsSNjIz6nCQLQPHsId8=" + }, + "org/apache/commons#commons-exec/1.3": { + "jar": "sha256-y0mBLcG/sOpPIPOYvK4aiMZAbiE+Z/dST7ENT4rZNHs=", + "pom": "sha256-goJ/YBnA9xvXT7qIarM3/22ikfY9+XIzeaIJ1q07RPg=" + }, + "org/apache/commons#commons-lang3/3.8.1": { + "jar": "sha256-2sgH9lsHaY/zmxsHv+89h64/1G2Ru/iivAKyqDFhb2g=", + "pom": "sha256-7I4J91QRaFIFvQ2deHLMNiLmfHbfRKCiJ7J4vqBEWNU=" + }, + "org/apache/commons#commons-parent/35": { + "pom": "sha256-cJihq4M27NTJ3CHLvKyGn4LGb2S4rE95iNQbT8tE5Jo=" + }, + "org/apache/commons#commons-parent/42": { + "pom": "sha256-zTE0lMZwtIPsJWlyrxaYszDlmPgHACNU63ZUefYEsJw=" + }, + "org/apache/commons#commons-parent/47": { + "pom": "sha256-io7LVwVTv58f+uIRqNTKnuYwwXr+WSkzaPunvZtC/Lc=" + }, + "org/hamcrest#hamcrest-core/1.3": { + "jar": "sha256-Zv3vkelzk0jfeglqo4SlaF9Oh1WEzOiThqekclHE2Ok=", + "pom": "sha256-/eOGp5BRc6GxA95quCBydYS1DQ4yKC4nl3h8IKZP+pM=" + }, + "org/hamcrest#hamcrest-parent/1.3": { + "pom": "sha256-bVNflO+2Y722gsnyelAzU5RogAlkK6epZ3UEvBvkEps=" + }, + "org/openjfx#javafx-base/17": { + "pom": "sha256-uLgDYSRg1flc6XS9XYRx1G4/aOzteCfdjUSRwDAi9yU=" + }, + "org/openjfx#javafx-base/17/linux": { + "jar": "sha256-JDzahjaTFMNLsQvgAj88mFaCNcpN7UpZ4Hgd1kC8SWI=" + }, + "org/openjfx#javafx-controls/17": { + "pom": "sha256-6UfbVFcEn1pKxmiSa2QUtLCRglYerVymiyNSTg4cwD8=" + }, + "org/openjfx#javafx-controls/17/linux": { + "jar": "sha256-pa085GMw/aiPjx4/ue8E1kR2O6C2mpXkl66JTjWdrQg=" + }, + "org/openjfx#javafx-fxml/17": { + "pom": "sha256-5+IA5aFv3qbIDne2IhWyVMt9thHEy9K9jGtVeLt39oE=" + }, + "org/openjfx#javafx-fxml/17/linux": { + "jar": "sha256-pkXtb3SSd3px+3c/IPO1OuIh9U0Fnl3p0dD2cmyam68=" + }, + "org/openjfx#javafx-graphics/17": { + "pom": "sha256-3RVlTvq6FiyolcdAxqA7vUEu8XNwyMcOq9j6PTUer+I=" + }, + "org/openjfx#javafx-graphics/17/linux": { + "jar": "sha256-YIAnF9iwTwE25rLNS5BGiQBSVml3328MF/dT+0eJ/aY=" + }, + "org/openjfx#javafx/17": { + "pom": "sha256-Mc+sHCBGlsqDJZzWCcK2kks3dBR+MOM9vEX+kKHnuww=" + }, + "org/sonatype/oss#oss-parent/7": { + "pom": "sha256-tR+IZ8kranIkmVV/w6H96ne9+e9XRyL+kM5DailVlFQ=" + } + } +} diff --git a/pkgs/by-name/ke/keyboard-layout-editor/fix-build-gradle.patch b/pkgs/by-name/ke/keyboard-layout-editor/fix-build-gradle.patch new file mode 100644 index 0000000000000..d14aba43db4b5 --- /dev/null +++ b/pkgs/by-name/ke/keyboard-layout-editor/fix-build-gradle.patch @@ -0,0 +1,95 @@ +diff --git a/build.gradle b/build.gradle +index b411200..a558065 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -1,5 +1,17 @@ ++buildscript { ++ repositories { ++ maven { ++ url "https://plugins.gradle.org/m2/" ++ } ++ } ++ dependencies { ++ classpath 'org.openjfx:javafx-plugin:0.1.0' ++ } ++} ++ + plugins { + id 'java' ++ id 'org.openjfx.javafxplugin' version '0.1.0' + } + + group 'cz.gresak' +@@ -12,22 +24,26 @@ repositories { + } + + dependencies { +- compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5' +- compile group: 'org.apache.commons', name: 'commons-exec', version: '1.3' +- compile group: 'commons-io', name: 'commons-io', version: '2.6' +- compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' ++ implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5' ++ implementation group: 'org.apache.commons', name: 'commons-exec', version: '1.3' ++ implementation group: 'commons-io', name: 'commons-io', version: '2.6' ++ implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' + +- testCompile group: 'junit', name: 'junit', version: '4.12' ++ testImplementation group: 'junit', name: 'junit', version: '4.12' + } + + compileJava { + options.encoding = 'UTF-8' + } + ++javafx { ++ modules = [ 'javafx.base', 'javafx.graphics', 'javafx.fxml' ] ++} ++ + jar { + manifest { + attributes( +- 'Class-Path': configurations.compile.collect { it.getName() }.join(' '), ++ 'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' '), + 'Main-Class': 'cz.gresak.keyboardeditor.Main' + ) + } +@@ -40,7 +56,8 @@ task fatJar(type: Jar) { + 'Implementation-Version': version, + 'Main-Class': 'cz.gresak.keyboardeditor.Main' + } +- baseName = project.name + '-all' +- from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } ++ archiveBaseName = project.name + '-all' ++ duplicatesStrategy = DuplicatesStrategy.EXCLUDE ++ from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + with jar + } +\ No newline at end of file +diff --git a/src/main/java/cz/gresak/keyboardeditor/component/Key.java b/src/main/java/cz/gresak/keyboardeditor/component/Key.java +index d81d66d..9530faf 100644 +--- a/src/main/java/cz/gresak/keyboardeditor/component/Key.java ++++ b/src/main/java/cz/gresak/keyboardeditor/component/Key.java +@@ -170,8 +170,8 @@ public class Key extends Pane { + bottomLeftChar.setLayoutY(bottomLine); + bottomRightChar.setLayoutY(bottomLine); + // horizontal alignment (needed only for the right column) +- double topLeftWidth = fontLoader.computeStringWidth(topLeftChar.getText(), topLeftChar.getFont()); +- double bottomLeftWidth = fontLoader.computeStringWidth(bottomLeftChar.getText(), bottomLeftChar.getFont()); ++ double topLeftWidth = 0.0; // fontLoader.computeStringWidth(topLeftChar.getText(), topLeftChar.getFont()); ++ double bottomLeftWidth = 0.0; // fontLoader.computeStringWidth(bottomLeftChar.getText(), bottomLeftChar.getFont()); + double maxLeftColumnLayoutX = Math.max(topLeftChar.getLayoutX(), bottomLeftChar.getLayoutX()); + double xOffset = Math.max( + (getWidth() / 2 - HPADDING) + KEY_COLUMN_SPACE, // center of the key +diff --git a/src/main/java/cz/gresak/keyboardeditor/service/impl/FontProviderImpl.java b/src/main/java/cz/gresak/keyboardeditor/service/impl/FontProviderImpl.java +index 4804505..a91ef5c 100644 +--- a/src/main/java/cz/gresak/keyboardeditor/service/impl/FontProviderImpl.java ++++ b/src/main/java/cz/gresak/keyboardeditor/service/impl/FontProviderImpl.java +@@ -81,7 +81,7 @@ public class FontProviderImpl implements FontProvider { + @Override + public double getFontSize(String text, Font font, double widthToFit, double heightToFit) { + FontLoader fontLoader = Toolkit.getToolkit().getFontLoader(); +- double sampleWidth = fontLoader.computeStringWidth(text, font); ++ double sampleWidth = 0.0; // fontLoader.computeStringWidth(text, font); + double fontSizeWidth = (widthToFit / sampleWidth) * font.getSize(); + + FontMetrics fontMetrics = fontLoader.getFontMetrics(font); diff --git a/pkgs/by-name/ke/keyboard-layout-editor/package.nix b/pkgs/by-name/ke/keyboard-layout-editor/package.nix new file mode 100644 index 0000000000000..ff88d38276139 --- /dev/null +++ b/pkgs/by-name/ke/keyboard-layout-editor/package.nix @@ -0,0 +1,73 @@ +{ + lib, + stdenv, + fetchFromGitHub, + gradle_8, + makeBinaryWrapper, + openjdk, + wrapGAppsHook3, + xorg, +}: + +let + jdk = openjdk.override { + enableJavaFX = true; + }; + +in +stdenv.mkDerivation rec { + pname = "keyboard-layout-editor"; + version = "0-unstable-2019-05-14"; + + src = fetchFromGitHub { + owner = "vgresak"; + repo = "keyboard-layout-editor"; + rev = "308c62ac4bb9ad25429f4d09c0aaa9f72d4194c9"; + hash = "sha256-ieXHgXAdC1xVJWXwpf9sQ9FaSLeaJfd+Rr7uD8blwHE="; + }; + + patches = [ ./fix-build-gradle.patch ]; + + nativeBuildInputs = [ + gradle_8 + makeBinaryWrapper + wrapGAppsHook3 + ]; + + mitmCache = gradle_8.fetchDeps { + inherit pname; + data = ./deps.json; + }; + + __darwinAllowLocalNetworking = true; + + gradleBuildTask = "fatJar"; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/java + cp build/libs/keyboard-layout-editor-all-1.0-SNAPSHOT.jar $out/share/java/keyboard-layout-editor.jar + mkdir -p $out/bin + makeWrapper ${lib.getExe jdk} $out/bin/keyboard-layout-editor \ + --prefix PATH : ${lib.makeBinPath [ xorg.xkbcomp ]} \ + --add-flags "--add-opens=javafx.graphics/com.sun.prism=ALL-UNNAMED" \ + --add-flags "--add-opens=javafx.graphics/com.sun.javafx.font=ALL-UNNAMED" \ + --add-flags "--add-opens=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED" \ + --add-flags "-cp $out/share/java/keyboard-layout-editor.jar cz.gresak.keyboardeditor.Main" \ + ''${gappsWrapperArgs[@]} + + runHook postInstall + ''; + + meta = { + description = "Keyboard layout editor for XKB"; + homepage = "https://github.com/vgresak/keyboard-layout-editor"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ fliegendewurst ]; + mainProgram = "keyboard-layout-editor"; + platforms = jdk.meta.platforms; + # gradle resolves platform-specific dependencies + broken = stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isDarwin; + }; +}