NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.96k stars 13.34k forks source link

Packaging request: Our Paint #208940

Open WesleyAC opened 1 year ago

WesleyAC commented 1 year ago

Project description

Our Paint is a featureless but programmable painting program.

Metadata

ChengduLittleA commented 1 year ago

I didn't anticipate Our Paint gets this much attention but thanks for showing interest :D

jonascarpay commented 1 year ago

I have a flake that manages to build (see below). When actually running, it expects the fonts to be in a particular location in the home folder, I haven't found a workaround for that yet. I'll open a PR once I can run it from this flake.

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-22.11";
  outputs = inputs:
    let
      system = "x86_64-linux";
      LaGUI = { stdenv, cmake, glew, freetype, libX11, libXi, libXcursor }: stdenv.mkDerivation {
        pname = "LaGUI";
        version = "5.0.0";
        src = builtins.fetchGit {
          url = "http://wellobserve.com/repositories/chengdulittlea/LaGUI.git";
          ref = "master";
          rev = "39b4062c583bfcd8e3157bd8077e7fddc52d8830";
        };
        nativeBuildInputs = [ cmake glew freetype libX11 libXi libXcursor ];
        buildPhase = ''
          export HOME=$TMP/tmphome
          mkdir build
          cd build
          cmake ..
          cd ..
          make
        '';
        postInstall = ''
          mv $HOME/.local/share $out
        '';
      };
      OurPaint = { stdenv, cmake, LaGUI, libGL, libX11, freetype, glew, lcms2, libXfixes, libXi, libXcursor }: stdenv.mkDerivation {
        pname = "OurPaint";
        version = "0.1";
        src = builtins.fetchGit {
          url = "http://wellobserve.com/repositories/chengdulittlea/OurPaint.git";
          ref = "master";
          rev = "e4cd5e734f289cd72a6fb95ea1a51d27e7f5157d";
        };
        nativeBuildInputs = [ cmake LaGUI libGL libX11 freetype glew lcms2 libXfixes libXi libXcursor ];
        buildPhase = ''
          mkdir build
          cd build
          cmake ..
          cd ..
          make
        '';
        installPhase = ''
          mkdir -p $out/bin
          mv OurPaint $out/bin/
        '';
      };
      overlay = final: prev: {
        OurPaint = final.callPackage OurPaint { };
        LaGUI = final.callPackage LaGUI { };
      };
    in
    {
      inherit overlay;
      packages.${system} =
        let
          pkgs = import inputs.nixpkgs {
            inherit system;
            overlays = [ overlay ];
          };
        in
        {
          inherit (pkgs) OurPaint LaGUI;
          default = pkgs.OurPaint;
        };
    };
}
jonascarpay commented 1 year ago

@ChengduLittleA Thanks for your work, I'm looking forward to playing around with this! The issue I run into is that Nix packages can't simply install fonts into the user directory. I want to patch in a different place to look for fonts, but I can't figure out what the best place for that would be. Any suggestions?

ChengduLittleA commented 1 year ago

Put the font folder directly adjacent to the executable should do the trick. There are 11 different relative/absolute paths that laGUI will search for its fonts. I will update the font configuration. In the source code... But I designed our paint to be portable so the font should come along with the software package (later I will include more custom font for icons). See my appimage for example

fgaz commented 1 year ago

I tried to package it in #209448. I don't know yet if it works because right now I'm on a computer with very low opengl version.

@ChengduLittleA could you add $PREFIX/share/fonts/lagui (or equivalent) to the font search path and have cmake install fonts there instead of in ~/.local? That would make this program easier to package. Alternatively, a cmake variable to set the location of existing fonts.

jonascarpay commented 1 year ago

Even if I put fonts in an expected location, I run into a segfault on startup. It might still be related to fonts (one fails to load for some reason), but either way there are more issues than just the font loading. Looking at the appimage script hasn't really helped me figure out what's up, so be warned I guess @fgaz

ChengduLittleA commented 1 year ago

@jonascarpay Any idea you could give me the stack trace on where it crashed? I think laGUI should not crash if there's at least one font that's loaded, so the crash might be other issue like graphics. (I later found out there's a typo in monospace font loader...)

@fgaz I updated CMake list to install fonts into a prefix if the variable is not manually set. Default is LAGUI_FONT_CUSTOM_PATH=$ENV{HOME}/.local/share/fonts/lagui . Go check out the latest code on my repo.

fgaz commented 1 year ago

It crashes for me too.

Stack trace of current head
                Stack trace of thread 2317:
                #0  0x00000000004aaf60 la_LabelGetMinWidth (OurPaint + 0xaaf60)
                #1  0x00000000004567fa la_AddRowNode (OurPaint + 0x567fa)
                #2  0x000000000045c6d7 la_UpdateUiListRecursive (OurPaint + 0x5c6d7)
                #3  0x000000000045de9d laEnclosePanelContent (OurPaint + 0x5de9d)
                #4  0x000000000045e0ff laEnableSplashPanel (OurPaint + 0x5e0ff)
                #5  0x00000000004329d7 our_EnableSplashPanel (OurPaint + 0x329d7)
                #6  0x000000000042d090 main (OurPaint + 0x2d090)
                #7  0x00007fe6db65424e __libc_start_call_main (libc.so.6 + 0x2924e)
                #8  0x00007fe6db654309 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x29309)
                #9  0x000000000042d1c5 _start (OurPaint + 0x2d1c5)

                Stack trace of thread 2319:
                #0  0x00007fe6db6b07d5 __futex_abstimed_wait_common (libc.so.6 + 0x857d5)
                #1  0x00007fe6db6b3202 pthread_cond_wait@@GLIBC_2.3.2 (libc.so.6 + 0x88202)
                #2  0x00007fe6d98c2199 cnd_wait (crocus_dri.so + 0x105199)
                #3  0x00007fe6d987407b util_queue_thread_func (crocus_dri.so + 0xb707b)
                #4  0x00007fe6d98c20d7 impl_thrd_routine (crocus_dri.so + 0x1050d7)
                #5  0x00007fe6db6b3e86 start_thread (libc.so.6 + 0x88e86)
                #6  0x00007fe6db73ad30 __clone3 (libc.so.6 + 0x10fd30)

                Stack trace of thread 2322:
                #0  0x00007fe6db6b07d5 __futex_abstimed_wait_common (libc.so.6 + 0x857d5)
                #1  0x00007fe6db6b3202 pthread_cond_wait@@GLIBC_2.3.2 (libc.so.6 + 0x88202)
                #2  0x00007fe6d98c2199 cnd_wait (crocus_dri.so + 0x105199)
                #3  0x00007fe6d987407b util_queue_thread_func (crocus_dri.so + 0xb707b)
                #4  0x00007fe6d98c20d7 impl_thrd_routine (crocus_dri.so + 0x1050d7)
                #5  0x00007fe6db6b3e86 start_thread (libc.so.6 + 0x88e86)
                #6  0x00007fe6db73ad30 __clone3 (libc.so.6 + 0x10fd30)

                Stack trace of thread 2318:
                #0  0x00007fe6db52c9fb longest_match (libz.so.1 + 0x49fb)
                #1  0x00007fe6db52e258 deflate_slow (libz.so.1 + 0x6258)
                #2  0x00007fe6db52f0c4 deflate (libz.so.1 + 0x70c4)
                #3  0x00007fe6d98788b6 util_compress_deflate (crocus_dri.so + 0xbb8b6)
                #4  0x00007fe6d986cc82 create_cache_item_header_and_blob (crocus_dri.so + 0xafc82)
                #5  0x00007fe6d986d5ba disk_cache_write_item_to_disk (crocus_dri.so + 0xb05ba)
                #6  0x00007fe6d986beb3 cache_put (crocus_dri.so + 0xaeeb3)
                #7  0x00007fe6d9874138 util_queue_thread_func (crocus_dri.so + 0xb7138)
                #8  0x00007fe6d98c20d7 impl_thrd_routine (crocus_dri.so + 0x1050d7)
                #9  0x00007fe6db6b3e86 start_thread (libc.so.6 + 0x88e86)
                #10 0x00007fe6db73ad30 __clone3 (libc.so.6 + 0x10fd30)
ChengduLittleA commented 1 year ago

@fgaz could be a GL context init problem. You could delete the preference file, or try v0.1b again

luzpaz commented 7 months ago

Any progress here ?