Nix shell libraries

I’m trying to install libraries and binaries for a development environment that then builds a electron app. However, when running electron, even though gtk3 is installed in nix-shell, since electron was not installed with nix it can’t find the library.

EDIT: The electron version I need is not available in nixpkgs. It’s being installed impurely via package scripts.
What’s the best way to work around this or get this working?

I’ve attached my nix-shell below

with import <nixpkgs> {};
mkShell {
        packages = [
                nodejs-14_x
                node2nix
                cups
        ];
        inputsFrom = [
                gtk3
                pkgconfig
        ];
}

Add electron to Nix, or manually add electron to PATH once you are in the shell. shellHook probably

The electron version that I need to use is no longer available in nixpkgs. It’s installed via electron-builder.

inputsFrom will copy inputs (dependencies) from the packages listed therein but not add the packages themselves:

You should move gtk3 to buildInputs and pkg-config to nativeBuildInputs (which packages is a synonym for).

I’ve rewritten it as follows

with import <nixpkgs> {};
mkShell {
        name = "my-package";
        packages = [
                nodejs-14_x
                node2nix
                cups
        ];
        buildInputs = [
                gtk3
        ];
        nativeBuildInputs = [
                pkgconfig
        ];
}

I’m still getting node_modules/electron/dist/electron: error while loading shared libraries: libgtk-3.so.0: cannot open shared object file: No such file or directory.

What should I set LD_LIBRARY_PATH to in this case? When I realize the mkShell derivation, I get the bash script that sets the envvars, but what I would want would be all the libraries in a single output, right?

Yeah, buildInputs will mostly just make the libraries available to ld (plus to pkg-config, when that is present). For runtime you will need to have something like LD_LIBRARY_PATH = "${gtk3}/lib" (or nicer LD_LIBRARY_PATH = lib.makeLibraryPath [ gtk3 ]). You can just pass the environment variable as an attribute to mkShell.