When I need to quickly compile some piece of code in NixOS I’d do the following:
[arno@nixos:~/srctest]$ git clone git://git.ffmpeg.org/rtmpdump
[arno@nixos:~/srctest]$ cd rtmpdump/
[arno@nixos:~/srctest/rtmpdump]$ nix-shell -p openssl zlib
[nix-shell:~/srctest/rtmpdump]$ make
...
[nix-shell:~/srctest/rtmpdump]$ exit
Make sure that all library dependencies are met
[arno@nixos:~/srctest/rtmpdump]$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:./librtmp"
[arno@nixos:~/srctest/rtmpdump]$ ldd rtmpdump
linux-vdso.so.1 (0x00007fff463f8000)
librtmp.so.1 => ./librtmp/librtmp.so.1 (0x00007fa277dbe000)
libssl.so.1.0.0 => /nix/store/y7p2f732xrdpyzvxx574q7zr7yi2rs9y-openssl-1.0.1k/lib/libssl.so.1.0.0 (0x00007fa277b51000)
libcrypto.so.1.0.0 => /nix/store/y7p2f732xrdpyzvxx574q7zr7yi2rs9y-openssl-1.0.1k/lib/libcrypto.so.1.0.0 (0x00007fa277769000)
libz.so.1 => /nix/store/584hmj4dvlp9aj9n4kcc52a5wz1aq9ac-zlib-1.2.8/lib/libz.so.1 (0x00007fa277551000)
libc.so.6 => /nix/store/la5imi1602jxhpds9675n2n2d0683lbq-glibc-2.20/lib/libc.so.6 (0x00007fa2771b4000)
libdl.so.2 => /nix/store/la5imi1602jxhpds9675n2n2d0683lbq-glibc-2.20/lib/libdl.so.2 (0x00007fa276fb0000)
/nix/store/la5imi1602jxhpds9675n2n2d0683lbq-glibc-2.20/lib/ld-linux-x86-64.so.2 (0x00007fa277fda000)
You can also find pkg-config useful
[arno@nixos:~/srctest/rtmpdump]$ nix-shell -p openssl zlib pkgconfig
[nix-shell:~/srctest/rtmpdump]$ pkg-config --list-all
...
[nix-shell:~/srctest/rtmpdump]$ pkg-config --libs sqlite3
-L/nix/store/69jq4mnkb3zvc0y2pk12cgrbq6by8n4p-sqlite-3.8.7.1/lib -lsqlite3
[nix-shell:~/srctest/rtmpdump]$ pkg-config --cflags sqlite3
-I/nix/store/69jq4mnkb3zvc0y2pk12cgrbq6by8n4p-sqlite-3.8.7.1/include
Thanks to ikwildrpepper #nixos for the nix-shell -p
tip.
More info here