Hey, I could use some help figuring out how to add libraries to the runtime of gramps. The addon Graph View needs dot from graphviz, and goocanvas at runtime and I cannot figure out how to add it to the pkg. I’ve been trying to search for it but nix documentation is somewhat difficult. Thank you!

  • hello_hello [comrade/them]@hexbear.netM
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    1 month ago

    You need to wrap Gramps with a PATH resource. A very easy way to do this is via a symlinkJoin on the gramps derivation which avoids needing to rebuild gramps.

    If you need a shared object library resource accessible at runtime, add a LD_LIBRARY_PATH resource.

    Here’s an example I’ve done with Emacs, which allows Emacs to access git, python3 and unzip binaries (my-emacs is a custom emacs derivation, replace with gramps)

    symlinkJoin {
      name = "my-emacs";
      paths = [ my-emacs ];
      buildInputs = [ makeBinaryWrapper ];
      postBuild = ''
        wrapProgram $out/bin/emacs \
          --suffix PATH : ${
            lib.makeBinPath [
              python3
              git
              unzip
            ]
          }
      '';
    }
    

    It should be the same for gramps. Avoid using propagatedBuildInputs since wrapping is much cleaner. Understanding how to feed packages resources they need at runtime via wrappers is a crucial concept in derivations since packages are isolated from each other. Recommend reading over nixpkgs derivations that use wrapProgram and get familiar with the syntax.

    • Thank you very much, I finally made it work.

      Here’s how I made it work:

      gramps.nix

      {
        lib,
        symlinkJoin,
        gramps,
        makeWrapper,
        graphviz,
        goocanvas3,
      }:
      symlinkJoin {
        name = "my-gramps";
        paths = [ gramps ];
        buildInputs = [ makeWrapper ];
        postBuild = ''
          wrapProgram $out/bin/gramps \
            --prefix GI_TYPELIB_PATH : ${
              lib.makeSearchPath "lib/girepository-1.0" [
                goocanvas3
                goocanvas3.dev
              ]
            } \
            --prefix PATH : ${
              lib.makeBinPath [
                graphviz
              ]
            }
        '';
      }
      

      Then simply (pkgs-unstable.callPackage ../programs/gramps.nix {}) in e.g. home.packages and it works!!!


      ⓘ 𝘛𝘩𝘪𝘴 𝘶𝘴𝘦𝘳 𝘪𝘴 𝘴𝘶𝘴𝘱𝘦𝘤𝘵𝘦𝘥 𝘰𝘧 𝘣𝘦𝘪𝘯𝘨 𝘢 𝘤𝘢𝘵. 𝘗𝘭𝘦𝘢𝘴𝘦 𝘳𝘦𝘱𝘰𝘳𝘵 𝘢𝘯𝘺 𝘴𝘶𝘴𝘱𝘪𝘤𝘪𝘰𝘶𝘴 𝘣𝘦𝘩𝘢𝘷𝘪𝘰𝘳.