I had success with setting a local prefix like --prefix="${PWD}/out" in the meson setup command. Then installing and running the application from there.
Edit: wait, nvm, I don’t think I actually dealt with gsettings before.
I still have no ideea how to deal with the gsettings thing; Now the schema is installed in the ./out folder, but it still gives the same error since the schema isn’t loaded in gsettings.
Haven’t tried, but maybe you can specify the path using an environment variable (GTK_PATH looks promising). Here is a list of all of them for GTK3 as well as some other things that might be useful when debugging: Gtk – 3.0: Running GTK Applications
If that doesn’t help, using strace, possibly together with gdb might help in figuring out where Settings is looking for things and how that path might be influenced. Ultimately, you could look into the GTK sources, but this can be a huge rabbit hole depending on how many layers of indirection they have so I usually try to get a good idea using strace at first.
The documentation for GNOME platform is in the Nixpkgs manual, including the description of requirements for GSettings.
Normally, the projects’ executables are wrapped to set relevant environment variables when packaged in Nixpkgs but that will not happen when trying to run a project unpackaged.
GTK_PATH is not relevant for settings, that is handled by GLib not GTK. The proper variable to set is XDG_DATA_DIRS.
With this, you can add $PWD/out/share to XDG_DATA_DIRS after the project is installed.
However, you should not need to install meson apps to run them. Meson has a devenv subcommand which allows running most project’s executables out of the build directory. Just make sure to call gnome.compile_schemas() function in the Meson build files. And if some other environment variables are needed, you can include them with meson.add_devenv().
If you want to use a derivation from Nixpkgs or any package set, you can just pass the set’s path as an argument to nix-shell. Plus -A followed by the attribute path of the derivation you want to use for shell:
nix-shell /path/to/nixpkgs -A swaynotificationcenter