これでどこでもgtkでいいじゃん

C

Dive into the environment:

nix-shell -p gtk3 gcc pkgconfig

And compile:

gcc `pkg-config --cflags gtk+-3.0` -o example example.c `pkg-config --libs gtk+-3.0`

That works.

Rust (updated at 2020-07-05)

If you need not to install your project as a nix package, just run:

$ nix-shell -p gtk3 pkgconfig

Rust

Start with the same approach:

$ nix-shell -p gtk3 pkgconfig rustc cargo llvm
$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s                                       
     Running `target/debug/gtktest`
thread 'main' panicked at 'libgtk-3 was configured with `--enable-debug=no`. See https://github.com/gtk-rs/gtk/issues/270 for details', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/gtk-0.5.0/src/rt.rs:137:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

So let's make an overlay:

self: super:
{
    gtk3RustDarwin = super.gtk3.overrideDerivation (attrs: { 
        configureFlags = [
            "--enable-debug"
            "--disable-dependency-tracking"
            "--disable-glibtest"
            "--enable-quartz-backend"
        ];
    });
}

What's overrideDerivation? It's a deprecated function. So the following seems better:

self: super:
{
    gtk3RustDarwin = super.gtk3.overrideAttrs (attrs: rec {
        configureFlags = [
            "--enable-debug"
            "--disable-dependency-tracking"
            "--disable-glibtest"
            "--enable-quartz-backend"
        ];
    });
}

Anyway, give it a try.

$ nix-shell -p gtk3RustDarwin pkgconfig rustc cargo llvm
$ cargo clean  # to purge the previous attempt
$ cargo run

That works!