Trying to package my first software for NixOS

I’m a new NixOS user, currently trying to get all the software up an running on a NixOS system (currently inside a VM, but hopefully on my laptop soon).
I was amazed to find packages for almost any software I wished for - great work!

Now there is one application for which no package exists and I am trying to find a configuration that installs it to my NixOS: JAlbum.
I’d appreciate if someone could help me find my way around the NixOS configuration to package this.

What I know about this software:

  • name: jalbum
  • version: 37.7
  • There is a ZIP download to execute it with any Java interpreter: https://download.jalbum.net/download/37.7/jAlbum.zip
    • sha256: QGy8agZ88Q0npcodnP6S/BF4lQEGbUMlQa8v7T2kNWU=
    • contains a folder jAlbum with many things, including
      • JAlbum.jar
      • icons/JalbumApp48.png
  • On my Linux Mint system Java is started with these arguments to run it:
    • -Xmx8000m --add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED -XX:+UseParallelGC -DmaxSubsampling=2 -DuseDesktop=true -jar /usr/lib/jalbum/JAlbum.jar
  • On NixOS I can start the application using java -jar /path/to/JAlbum.jar with this in my configuration:
programs.java = {
      enable = true;
      package = pkgs.jdk23.override { enableJavaFX = true; };
    };

What I think the package should do:

  • Include pkgs.jdk23 with JavaFX enabled or depend on it.
  • download the ZIP + check sha256
  • extract it to an appropriate location
  • create a starter script that calls Java with all the arguments
  • Create a .desktop launcher to make it show up in the menu (I am using KDE Plasma, in case that matters)

I don’t really know how to start – found some hints on the internet so I have a very vague understanding, but I’m not able to get it to work by myself.
Is the information above everything we need to create a custom package in my configuration?
How to proceed?

Some starting info:

Specifically in this case, you’re going to need to poke around the provided zip a bit, and see if they provide a starter script or something. If so, you’ll probably want to wrap it with makeWrapper, and possibly modify it a bit first with substituteInPlace. If not, you’ll just want to make one (actually, you may want to make it with makeWrapper anyway, just wrap the java binary and add additional arguments).

They probably also don’t provide a FHS-style directory structure (bin, share, lib, etc), so you’ll need to at least minimally conform to that, maybe by throwing everything in $out/share/jalbum or the like.

Here’s an example of a derivation for a java-based game in nixpkgs:

In this case, the game provides a shell script intended for starting it, and the derivation modifies and wraps that.

Great – thanks for pointing me into the right direction!

Looks like I’ll have to do some reading… :slight_smile:

1 Like