NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.62k stars 13.77k forks source link

Trying to package Manager.io #30926

Open CMCDragonkai opened 6 years ago

CMCDragonkai commented 6 years ago

I'm trying to package Manager which is built ontop of Mono.

They are now distributing versioned debian archives. It's debian information is:

[nix-shell:~/Projects/manager]$ dpkg -I ./Manager.deb 
 new debian package, version 2.0.
 size 8167230 bytes: control archive=1586 bytes.
     561 bytes,    13 lines      control              
    2440 bytes,    31 lines      md5sums              
 Package: manager-accounting
 Version: 17.10.66
 Architecture: amd64
 Maintainer: Lubos Hasko <lubos@luboshasko.com>
 Installed-Size: 19790
 Depends: libc6 (>= 2.14), mono-runtime, libmono-system-xaml4.0-cil, mono-devel, libgtk2.0-cil-dev, libwebkit1.1-cil
 Section: misc
 Priority: extra
 Homepage: http://www.manager.io/
 Description: Accounting software
  Manager is free accounting software for Ubuntu. It features an intuitive
  and innovative user interface with modules such as cashbook, invoicing,
  receivables, payables, taxes and comprehensive financial reports.

It relies on the mono-runtime and mono-devel, which I think is provided by mono package, and the libgtk2.0-cil-dev which I think is supplied by gtk-sharp-2_0. However the other dependencies, I'm not sure about. That is libmono-system-xaml4.0-cil, and libwebkit1.1-cil. I think the libwebkit1.1-cil should be provided by a webkit-sharp package, but nobody has done this yet.

My only reference for how to do this would be: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/tomboy/default.nix

But I'm not sure how difficult it is to get libwebkit-sharp packaged since libwebkit doesn't even exist in nixpkgs at the moment?

Is the xaml dependency available as well, or already part of the mono package?

Also what's the difference between *-sharp packages and dotnetPackages.* packages?

CMCDragonkai commented 5 years ago

Since I posted this last year, Manager has been updated.

Now when you download the source package: https://d2ap5zrlkavzl7.cloudfront.net/18.11.5/manager-accounting.zip

You can see that its debian files state that its dependencies are now (the control file):

Depends: libc6 (>= 2.14), mono-runtime, mono-devel, libgtk3.0-cil, libwebkit2gtk-4.0-37

This is alot easier as now Nixpkgs has al l these dependencies.

However currently libgtk3.0-cil is marked as broken, so it won't be possible to use at this moment.

As a side note:

The manager-accounting that is being executed is a shell script inside /opt/manager-accounting/manager-accounting. The shell script uses the cli which is the common language infrastructure interpreter and calls the /opt/manager-accounting/ManagerDesktop.exe. I'm guessing we have the same issue when using the ManagerServer.exe as well. And we can expose both. And that's a PE32 executable GUI for MS Windows.

The whole source archive contains:

/debian
/opt
/usr

So when this gets turned into a derivation, something needs to use some sort of debian builder to build this. Something like debhelper. And a bunch of shell script paths needs to be rewritten.

CMCDragonkai commented 5 years ago

In Debian they have "packages" and "source packages". For example libgtk3.0-cil is a "package" that is based off a source package called gtk-sharp3. In Nixpkgs, we do not have this difference, we have packages and derivations. But we name them the same thing (even src is itself a derivation of some sort). So when a Debian package wants libgtk3.0-cil, you look this up and find that Debian says it is based on a source package called gtk-sharp3. Then you can search Nixpkgs for something that looks like gtk-sharp3.

For example:

A "source package" called webkit-sharp https://packages.debian.org/source/jessie/webkit-sharp produces 3 binary packages:

The actual upstream for the source package is at: https://github.com/mono/webkit-sharp

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
CMCDragonkai commented 2 years ago

Manager.io is now an app image.

I've followed the nixpkgs manual to wrap it.

  manager = self.appimageTools.wrapType2 {
    name = "manager";
    src = self.fetchurl {
      url = "https://github.com/Manager-io/Manager.AppImage/releases/download/21.11.58/Manager-x64.AppImage";
      sha256 = "17vxy69ifdxdm2ylfhc3vqmlya4szjszg4kb539kp1mj147mmxr2";
    };
    extraPkgs = pkgs: with pkgs; [ icu webkit2-sharp webkitgtk ];
  };

This gives us an executable that doesn't complain but produces a blank screen.

»» /nix/store/l0ld2xkizlirb2bv13xwb3p9xr8lcddz-manager/bin
 ♜ ./manager                                                                                                 pts/4 19:32:36
Gtk-Message: 19:32:38.093: Failed to load module "window-decorations-gtk-module"
Gtk-Message: 19:32:38.094: Failed to load module "colorreload-gtk-module"
Gtk-Message: 19:32:38.330: Failed to load module "window-decorations-gtk-module"
Gtk-Message: 19:32:38.330: Failed to load module "colorreload-gtk-module"

Not sure what's missing here.

CMCDragonkai commented 2 years ago

Shooting in the dark, but still no luck:

  manager = self.appimageTools.wrapType2 {
    name = "manager";
    src = self.fetchurl {
      url = "https://github.com/Manager-io/Manager.AppImage/releases/download/21.11.58/Manager-x64.AppImage";
      sha256 = "17vxy69ifdxdm2ylfhc3vqmlya4szjszg4kb539kp1mj147mmxr2";
    };
    extraPkgs = pkgs: with pkgs; [ icu webkit2-sharp webkitgtk gtk-sharp-3_0 gtk3 mono ];
  };
CMCDragonkai commented 10 months ago

Recent attempt!

»» ~/Downloads
 ♖ nix-shell -p appimage-run                              ⚡(master) pts/3 8:49:28

[nix-shell:~/Downloads]$ appimage-run ./Manager-linux-x64.AppImage 
Uncompress Manager-linux-x64.AppImage of type 02 @ offset 594264
[===================================================================|] 863/863 100%
Manager-linux-x64.AppImage is now installed in /home/cmcdragonkai/.cache/appimage-run/a31f1a257d112e75841c6aa6a86cab75f3f18bcf39a34583bb97295049c9653d
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode+Settings..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.CultureData.GetCultureData(System.String, Boolean)
   at System.Globalization.CultureInfo..ctor(System.String, Boolean)
   at System.Reflection.AssemblyName..ctor(System.Reflection.NativeAssemblyNameParts*)
   at System.RuntimeTypeHandle.GetTypeByName(System.String, Boolean, Boolean, System.Runtime.CompilerServices.StackCrawlMarkHandle, System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.ObjectHandleOnStack, System.Runtime.CompilerServices.ObjectHandleOnStack)
   at System.RuntimeTypeHandle.GetTypeByName(System.String, Boolean, Boolean, System.Threading.StackCrawlMark ByRef, System.Runtime.Loader.AssemblyLoadContext)
   at System.Type.GetType(System.String)
   at Eto.OperatingSystemPlatform..ctor()
   at Eto.EtoEnvironment.get_Platform()
   at Eto.Platform.get_Detect()
   at Eto.Forms.Application..ctor()
   at ManagerDesktop.Program.Main(System.String[])
/home/cmcdragonkai/.cache/appimage-run/a31f1a257d112e75841c6aa6a86cab75f3f18bcf39a34583bb97295049c9653d/AppRun: line 4:    72 Aborted                 (core dumped) ${HERE}/opt/manager/ManagerDesktop

How does one use appimage-run with additional libraries? I think I already know about icu above.

tomodachi94 commented 4 months ago

How does one use appimage-run with additional libraries? I think I already know about icu above.

I'd approach this by extracting the AppImage (./Manager-linux-x64.AppImage --appimage-extract) and then using autoPatchelfHook on the resulting binaries.

CMCDragonkai commented 4 months ago

There's still a missing library dependency though.

tomodachi94 commented 4 months ago

You can use this command from the patchelf (nix-shell -p patchelf) package to determine what dependencies are needed by the binary. (Upstreams occasionally don't list some libraries assumed to be available on all machines):

patchelf --print-needed path/to/binary/in-extracted/manager

Sorry if I'm misunderstanding.

Edit: For more tips on packaging binaries, check out this wiki page.