Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freej2me: init at 0-unstable-2024-02-16 #326677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sigmanificient
Copy link
Member

@Sigmanificient Sigmanificient commented Jul 12, 2024

Description of changes

Fix:

file="~/Download/splinter_cell_double_240x320_147976.jar"
java -jar result/share/java/freej2me-sdl.jar "file://$file" 240 320

image

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@Kreyren
Copy link
Contributor

Kreyren commented Jul 13, 2024

# https://phoneky.com/games/?id=j3j89646
$ sha256sum ~/Downloads/splinter_cell_double_240x320_147976.jar
7454b5481f01ea470835e686df78ea142853ddf963d9444822cfac93c31cdfbf  /home/kreyren/Downloads/splinter_cell_double_240x320_147976.jar
$ export file="~/Download/splinter_cell_double_240x320_147976.jar"
$ NIXPKGS_ALLOW_INSECURE=1 nix shell 'github:Sigmanificient/nixpkgs/J2ME#j2me' 'github:nixos/nixpkgs#pkgs.jdk' --impure --command java $(NIXPKGS_ALLOW_INSECURE=1 nix eval 'github:Sigmanificient/nixpkgs/J2ME#j2me.outPath' --impure --raw)/share/java/freej2me-sdl.jar "file://$file" 240 320
Error: Could not find or load main class .nix.store.65zhxs2zaix6jrcjm8x0dpv5wgs645sm-j2me-0-unstable-2024-02-16.share.java.freej2me-sdl.jar
Caused by: java.lang.ClassNotFoundException: /nix/store/65zhxs2zaix6jrcjm8x0dpv5wgs645sm-j2me-0-unstable-2024-02-16/share/java/freej2me-sdl/jar
$ ls /nix/store/65zhxs2zaix6jrcjm8x0dpv5wgs645sm-j2me-0-unstable-2024-02-16/share/java/
freej2me.jar  freej2me-lr.jar  freej2me-sdl.jar

Doesn't seem to work on my end :(

NixOS Config Reference: https://github.com/NiXium-org/NiXium/tree/db7f7af8a4c278f1e9f7d77c56c66e6b18419e6e/src/nixos/machines/sinnenfreude

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Jul 13, 2024
lib/licenses.nix Outdated Show resolved Hide resolved
pkgs/by-name/j2/j2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/j2/j2me/package.nix Outdated Show resolved Hide resolved
@Kreyren
Copy link
Contributor

Kreyren commented Jul 13, 2024

Could this be made to build on armv7l-linux? I would like to use it on Nokia N900 (NiXium-org/NiXium#119)

@ofborg build pkgsCross.armv7l-hf-multiplatform.j2me


NIXPKGS_ALLOW_INSECURE=1 nix build 'github:Sigmanificient/nixpkgs/J2ME#pkgsCross.armv7l-hf-multiplatform.j2me' --impure -v
https://gist.githubusercontent.com/Kreyren/7a1fbe96d5c140c63c6bff3d41959a27/raw/6baac5a3d63bb1edc51602935e9607d10b588161/gistfile1.txt

@Sigmanificient
Copy link
Member Author

Sigmanificient commented Jul 13, 2024

# https://phoneky.com/games/?id=j3j89646
$ sha256sum ~/Downloads/splinter_cell_double_240x320_147976.jar
7454b5481f01ea470835e686df78ea142853ddf963d9444822cfac93c31cdfbf  /home/kreyren/Downloads/splinter_cell_double_240x320_147976.jar
$ export file="~/Download/splinter_cell_double_240x320_147976.jar"
$ NIXPKGS_ALLOW_INSECURE=1 nix shell 'github:Sigmanificient/nixpkgs/J2ME#j2me' 'github:nixos/nixpkgs#pkgs.jdk' --impure --command java $(NIXPKGS_ALLOW_INSECURE=1 nix eval 'github:Sigmanificient/nixpkgs/J2ME#j2me.outPath' --impure --raw)/share/java/freej2me-sdl.jar "file://$file" 240 320
Error: Could not find or load main class .nix.store.65zhxs2zaix6jrcjm8x0dpv5wgs645sm-j2me-0-unstable-2024-02-16.share.java.freej2me-sdl.jar
Caused by: java.lang.ClassNotFoundException: /nix/store/65zhxs2zaix6jrcjm8x0dpv5wgs645sm-j2me-0-unstable-2024-02-16/share/java/freej2me-sdl/jar
$ ls /nix/store/65zhxs2zaix6jrcjm8x0dpv5wgs645sm-j2me-0-unstable-2024-02-16/share/java/
freej2me.jar  freej2me-lr.jar  freej2me-sdl.jar

Doesn't seem to work on my end :(

NixOS Config Reference: NiXium-org/NiXium@db7f7af/src/nixos/machines/sinnenfreude

Try using

file=$(realpath ~/Downloads/splinter_cell_double_240x320_147976.jar)
java -jar result/share/java/freej2me-sdl.jar "file://$file" 240 320

(added realpath because it requires an absolute path)
Maybe i should add this script in bin?

@Sigmanificient Sigmanificient changed the title j2me: init at 0-unstable-2024-02-16 freej2me: init at 0-unstable-2024-02-16 Jul 13, 2024
@Kreyren
Copy link
Contributor

Kreyren commented Jul 13, 2024

Try using [absolute path] -- @Sigmanificient (#326677 (comment))

Same problem:

$ export file="$(realpath ~/Downloads/splinter_cell_double_240x320_147976.jar)
$ NIXPKGS_ALLOW_INSECURE=1 nix shell 'github:Sigmanificient/nixpkgs/J2ME#freej2me' 'github:nixos/nixpkgs#pkgs.jdk' --impure --command java $(NIXPKGS_ALLOW_INSECURE=1 nix eval 'github:Sigmanificient/nixpkgs/J2ME#freej2me.outPath' --impure --raw)/share/java/freej2me-sdl.jar "file://$file" 240 320
Error: Could not find or load main class .nix.store.3qyg23lzkmc6j2509wz8ll4nqqflygf7-freej2me-0-unstable-2024-02-16.share.java.freej2me-sdl.jar
Caused by: java.lang.ClassNotFoundException: /nix/store/3qyg23lzkmc6j2509wz8ll4nqqflygf7-freej2me-0-unstable-2024-02-16/share/java/freej2me-sdl/jar

Maybe i should add this script in bin? -- @Sigmanificient (#326677 (comment))

Unsure if that's the NixOS-way to handle this scenario, but it would be preferable if i could just do $ freej2me path/to/game args

@Sigmanificient
Copy link
Member Author

Sigmanificient commented Jul 14, 2024

I added a small runner using WriteShellScriptBin, the implementation is a bit wanky but i don't see how to improve it

pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
@Kreyren
Copy link
Contributor

Kreyren commented Jul 14, 2024

The Game now works with the script tested using:

$ NIXPKGS_ALLOW_INSECURE=1 nix shell 'github:Sigmanificient/nixpkgs/eccc7656d245800cb0b75bf95780549a30e62f13#freej2me' --impure --command $(NIXPKGS_ALLOW_INSECURE=1 nix eval 'github:Sigmanificient/nixpkgs/J2ME#freej2me.outPath' --impure --raw)/bin/freej2me freej2me-sdl "$file" 240 320

image

but it originally loaded in like 1x5 px window that i nearly misses and though that it's broken.. seems that the height and width is not parsed correctly

@Kreyren
Copy link
Contributor

Kreyren commented Jul 14, 2024

This line is the window that it opens:

image

lib/licenses.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Show resolved Hide resolved
@Kreyren
Copy link
Contributor

Kreyren commented Jul 16, 2024

The darwin build started 2 days ago and still didn't finish -> Probably adjust meta.platforms ?

@eclairevoyant
Copy link
Contributor

eclairevoyant commented Jul 16, 2024

No need, it's just slow. And it'll get skipped anyway due to the insecure dep (freeimage).

On that note, I don't think we should introduce this into nixpkgs. We're trying to get rid of dependency on freeimage, not add more.

@Kreyren
Copy link
Contributor

Kreyren commented Jul 16, 2024

On that note, I don't think we should introduce this into nixpkgs. We're trying to get rid of dependency on freeimage, not add more. -- @eclairevoyant (#326677 (comment))

Would agree, but it seems to be the only option for J2ME gaming which i would like to use on my Nokia N900 so like ideally if we could give it the steam treatment or alike?

@Sigmanificient
Copy link
Member Author

Everything is now resolved 😅

@Sigmanificient
Copy link
Member Author

@Kreyren

Splitted the script into individuals script, using a generic function.
Here is the demo screenshot (used result/bin/freej2me)

image

@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

The only thing that uses Freeimage is @hex007 's SDL interface, which like the Libretro core, is completely optional. -- @recompileorg (hex007/freej2me#221 (comment))

@Sigmanificient How does this affect things in practice on NixOS?

@Sigmanificient
Copy link
Member Author

Sigmanificient commented Jul 21, 2024

The only thing that uses Freeimage is @hex007 's SDL interface, which like the Libretro core, is completely optional. -- @recompileorg (hex007/freej2me#221 (comment))

@Sigmanificient How does this affect things in practice on NixOS?

Dropped the SDL front-end, which was optional anyway. java and libretro implementation are remaining so it is still interesting to have it around, has it still has the core part of the project.

@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

Tested using:

$ nix shell 'github:Sigmanificient/nixpkgs/d0a31fee2e0831fc243a2cfa09f1c73e351ac9ee#freej2me' --command $(nix eval 'github:Sigmanificient/nixpkgs/d0a31fee2e0831fc243a2cfa09f1c73e351ac9ee#freej2me.outPath' --raw)/bin/freej2me "$file" 240 320

Seems that all issues that i've highlighted were fixes as tested on Sinnenfreude (Presently a NixOS x86_64 system with configuration at https://github.com/NiXium-org/NiXium/tree/ec5a7e8b4f113de4cbd295221d6265e52454d629/src/nixos/machines/sinnenfreude)

I know that the architecture of Nokia N900 is not officially supported, but ideally i would like to use this package there which still doesn't seem to work:

$ nix shell --system armv7l-linux 'github:Sigmanificient/nixpkgs/d0a31fee2e0831fc243a2cfa09f1c73e351ac9ee#freej2me' --command $(nix eval 'github:Sigmanificient/nixpkgs/d0a31fee2e0831fc243a2cfa09f1c73e351ac9ee#freej2me.outPath' --raw)/bin/freej2me "$file" 240 320
error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'freej2me-0-unstable-2024-02-16'
         whose name attribute is located at /nix/store/v120g049zi5j2vmhrp90clwjz8khjnjl-source/pkgs/stdenv/generic/make-derivation.nix:334:7

       … while evaluating attribute 'installPhase' of derivation 'freej2me-0-unstable-2024-02-16'

         at /nix/store/v120g049zi5j2vmhrp90clwjz8khjnjl-source/pkgs/by-name/fr/freej2me/package.nix:47:3:

           46|
           47|   installPhase = let
             |   ^
           48|     mk-script-bin = frondend: writeShellScriptBin frondend ''

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: unsupported CPU armv7l

As tested on mentioned x86_64 with binfmt set for armv7l-linux assuming that's the correct triplet for TI OMAP 3430 SoC

@Sigmanificient is that something that you would like to address as well?

Additional note: I can't currently test it on the bare hardware as i am still working on NiXium-org/NiXium#119 (waiting for a new battery to arrive which should be there soon and then deploying NixOS unsure about any roadblocks there)

Alternatively i will be working on a new PCB for this device taking over some of the work of neo900 while forking probably OLIMEX or BeagleDev's design in case there is more suitable SoC for this usecase (riscv64?).

EDIT: Also depends on #328952, but the device can also work on xfce which should enable testing

@Sigmanificient
Copy link
Member Author

Sigmanificient commented Jul 21, 2024

I would love to help, but honestly not even sure how to get started, on making it work on such platform

@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

I would love to help, but honestly not even sure how to get started, on making it work on such platform -- @Sigmanificient (#326677 (comment))

Looking on the NixOS Packages it seems that it might already have everything needed with the exception of #328952 to at least run on the device using xfce or i3wm like postmarketOS is currently doing and in a way that would build on the platform, but there seems to be an issue with Nix doesn't allowing to even evaluate the package for this platform atm with the error: unsupported CPU armv7l .

Maybe we just need to adjust the meta.platforms ?

CC @K900 @samueldr @ryan4yin (The NixOS On Arm Team), issue mentioned in their matrix room as well

Sidenote: The SoC is Texas Instruments OMAP 3 an armv7 SoC with linux mainline support.

pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
@Sigmanificient
Copy link
Member Author

Oh wow, that a lot of changes 😅

@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

Oh wow, that a lot of changes 😅 -- @Sigmanificient (#326677 (comment))

Small nitpicks + wrong error output, sorry if it's overwhelming 🙏

@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

Doing 3e24fd5 (#326677) doesn't seem to fix the error: unsupported CPU armv7l on system with boot.binfmt.emulatedSystems = [ "armv7l-linux" ]; set as seen in https://github.com/NiXium-org/NiXium/blob/ec5a7e8b4f113de4cbd295221d6265e52454d629/src/nixos/machines/sinnenfreude/services/binfmt.nix#L9 and tested using:

$ nix shell --system armv7l-linux 'github:Sigmanificient/nixpkgs/3e24fd58c3931c5a9d673ce08f68dbb21c412056#freej2me' --command $(nix eval 'github:Sigmanificient/nixpkgs/3e24fd58c3931c5a9d673ce08f68dbb21c412056#freej2me.outPath' --raw)/bin/freej2me "$file" 240 320

pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/fr/freej2me/package.nix Outdated Show resolved Hide resolved
@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

Otherwise the merge request is LGTM with the exception of it not building for the Nokia N900, maybe make that a separate merge request to not make this one too complicated? @alyssais @eclairevoyant opinion?

@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

Referencing: https://matrix.to/#/!kjdutkOsheZdjqYmqp:nixos.org/$GGyXMPvmdLRoEC0B6eLpj_ZCkTCTj7piUE72K6GRoEw?via=nixos.org&via=matrix.org&via=nixos.dev

As understood it seems that the issue is with openjdk21 not having the platform defined upstream, might work with openjdk19 or lower -> Check if it works with that and probably make a new merge request so that we can see what needs to be done and to request upstream to support that platform?

freej2me: drop SDL frontend

free2jme: refactor

test set meta.platforms = all
@Kreyren
Copy link
Contributor

Kreyren commented Jul 21, 2024

Currently building:

$ NIXPKGS_ALLOW_INSECURE=1 nix shell --impure --system armv7l-linux 'github:Sigmanificient/nixpkgs/fa05a68ae0e8bfffb84e16023c7a3827fc56fd41#freej2me' --command $(NIXPKGS_ALLOW_INSECURE=1 nix eval 'github:Sigmanificient/nixpkgs/fa05a68ae0e8bfffb84e16023c7a3827fc56fd41#freej2me.outPath' --impure --raw)/bin/freej2me "$file" 240 320

So far that openjdk19 seems to be building fine for armv7l-linux, i guess we can keep this for now and then handle the openjdk21 upstream to then bump this if it works?

EDIT: That doesn't seem like a good idea considering that it's openjdk19 is EOL. I guess the modern version should be used until the upstream is adjusted.

UPDATE(23rd Jul 24): Still building..

@Kreyren
Copy link
Contributor

Kreyren commented Jul 23, 2024

As calculated it seems like it would take at least 8 days to builds rn as i am reworking NiXium's compute server and other systems lack the system resources for binfmt, cross-compilation would probably take much less time i try to put together a quick system out of parts tomorrow to verify the build, but i think we can assume that it will build and rather request the openjdk21 upstream to support this platform or patch the support in?

@Kreyren
Copy link
Contributor

Kreyren commented Jul 24, 2024

Referencing a discussion on the subject of caching armv7l platform in nix devel channel

Apparently the strategy is that since a powerful enough armv7 system does not exist atm and the best we can get is something like banana pi m3 which is octa-core Cortex-A7 (i was given this system to get on my 3D printer, but it has lot of architecture induced issues that makes me not wanting to use it, but it might address this problem) the expected strategy is to adjust the packages to be cross-compiling and declare them into https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/release-cross.nix to cache them as cross-compiled cache with the included impurities from cross-compiling

Alternative to use arm's compatibility mode was proposed unsure if it's able to provide us with a native armv7 platform for hydra to process, if so it would solve the issue in a way that doesn't obstruct hydra's current runtime abilities for the currently supported platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants