  def _get_option_parser():
      parser = optparse.OptionParser('%prog [options] sources')
      parser.add_option('', "--quiet",
-@@ -200,6 +233,10 @@ match the namespace prefix.""")
+@@ -209,6 +242,10 @@
      parser.add_option("", "--filelist",
                        action="store", dest="filelist", default=[],
                        help="file containing headers and sources to be scanned")

diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 89ec193..54f1d2e 100755
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -94,6 +94,39 @@ def get_windows_option_group(parser):
     return group
 
 

 
     group = get_preprocessor_option_group(parser)
     parser.add_option_group(group)
--- a/giscanner/shlibs.py
+++ b/giscanner/shlibs.py
@@ -63,6 +63,11 @@
         pattern = "([^\s]*lib*%s[^A-Za-z0-9_-][^\s\(\)]*)"
     return re.compile(pattern % re.escape(library_name))
 
+def _ldd_library_nix_pattern(library_name):
+    nix_store_dir = re.escape('@nixStoreDir@'.rstrip('/'))
+    pattern = r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)'
+    return re.compile(pattern % (nix_store_dir, re.escape(library_name)))
+
 
 # This is a what we do for non-la files. We assume that we are on an
 # ELF-like system where ldd exists and the soname extracted with ldd is
@@ -112,7 +117,7 @@
         proc = subprocess.Popen(args, stdout=subprocess.PIPE)
         patterns = {}
         for library in libraries:
-            patterns[library] = _ldd_library_pattern(library)
+            patterns[library] = (_ldd_library_pattern(library), _ldd_library_nix_pattern(library))
 
         shlibs = []
         for line in proc.stdout:
@@ -122,11 +127,14 @@
             # possible for the name of the binary to match _ldd_library_pattern.
             if line == binary.args[0] + ':\n':
                 continue
-            for library, pattern in patterns.items():
-                m = pattern.search(line)
+            for library, (pattern, nix_pattern) in patterns.items():
+                if line.find('@nixStoreDir@') != -1:
+                    m = nix_pattern.search(line)
+                else:
+                    m = pattern.search(line)
                 if m:
                     del patterns[library]
-                    shlibs.append(m.group(1))
+                    shlibs.append(os.path.join(options.fallback_libpath, m.group(1)))
                     break
 
         if len(patterns) > 0:
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -113,17 +113,11 @@
     if dlname is None:
         return None
 
