1diff --git a/src/terralib.lua b/src/terralib.lua
2index 532ed18..2c265dc 100644
3--- a/src/terralib.lua
4+++ b/src/terralib.lua
5@@ -3426,6 +3426,16 @@ function terra.includecstring(code,cargs,target)
6 args:insert("-internal-isystem")
7 args:insert(path)
8 end
9+ -- NOTE(aseipp): include relevant Nix header files
10+ args:insert("-isystem")
11+ args:insert("@NIX_LIBC_INCLUDE@")
12+
13+ local nix_cflags = os.getenv('NIX_CFLAGS_COMPILE')
14+ if nix_cflags ~= nil then
15+ for w in nix_cflags:gmatch("%S+") do
16+ args:insert(w)
17+ end
18+ end
19 -- Obey the SDKROOT variable on macOS to match Clang behavior.
20 local sdkroot = os.getenv("SDKROOT")
21 if sdkroot then