summary refs log tree commit diff
path: root/lib/strings.nix
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-04-13 15:33:21 +0300
committerNikolay Amiantov <ab@fmap.me>2016-04-13 22:05:45 +0300
commit2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50 (patch)
tree48b7aa2c5fd306bf2230c833df2c96d7d7e075ef /lib/strings.nix
parent338340f993563551d8cb45941da987408abef65f (diff)
downloadnixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.tar
nixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.tar.gz
nixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.tar.bz2
nixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.tar.lz
nixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.tar.xz
nixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.tar.zst
nixlib-2a3b3d6f8b75eb10ab638d32c163bc6ca798ae50.zip
makeSearchPathOutputs: init function
Diffstat (limited to 'lib/strings.nix')
-rw-r--r--lib/strings.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index 6818e589bc1c..30c24f7bde5a 100644
--- a/lib/strings.nix
+++ b/lib/strings.nix
@@ -88,6 +88,16 @@ rec {
   makeSearchPath = subDir: packages:
     concatStringsSep ":" (map (path: path + "/" + subDir) packages);
 
+  /* Construct a Unix-style search path, given trying outputs in order.
+     If no output is found, fallback to `.out` and then to the default.
+
+     Example:
+       makeSearchPathOutputs "bin" ["bin"] [ pkgs.openssl pkgs.zlib ]
+       => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-bin/bin:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/bin"
+  */
+  makeSearchPathOutputs = subDir: outputs: pkgs:
+    makeSearchPath subDir (map (lib.tryAttrs (outputs ++ ["out"])) pkgs);
+
   /* Construct a library search path (such as RPATH) containing the
      libraries for a set of packages