diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2016-05-13 10:14:53 +0200 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2016-05-13 10:14:53 +0200 |
commit | 3e387c3e005c87566b5403d24c86f71f4945a79b (patch) | |
tree | 6ddd883a2e405850093d1f19cd18bb9b712e7c01 /lib | |
parent | df8958435e1fd0c6d55394e95d3d3d2e0edca474 (diff) | |
parent | 6c2fbfbd7720446821be2a506cefcd1e0ff3b42d (diff) |
Merge branch 'staging'
Darwin isn't in a perfect state, in particular its bootstrap tools won't build which will block nixpkgs channel. But on the whole it seems acceptable.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/attrsets.nix | 26 | ||||
-rw-r--r-- | lib/strings.nix | 19 |
2 files changed, 19 insertions, 26 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 70986195ae054..636cb257d6bf5 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -438,23 +438,21 @@ rec { overrideExisting = old: new: old // listToAttrs (map (attr: nameValuePair attr (attrByPath [attr] old.${attr} new)) (attrNames old)); - /* Try given attributes in order. If no attributes are found, return - attribute list itself. + /* Get a package output. + If no output is found, fallback to `.out` and then to the default. Example: - tryAttrs ["a" "b"] { a = 1; b = 2; } - => 1 - tryAttrs ["a" "b"] { c = 3; } - => { c = 3; } + getOutput "dev" pkgs.openssl + => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev" */ - tryAttrs = allAttrs: set: - let tryAttrs_ = attrs: - if attrs == [] then set - else - (let h = head attrs; in - if hasAttr h set then getAttr h set - else tryAttrs_ (tail attrs)); - in tryAttrs_ allAttrs; + getOutput = output: pkg: + if pkg.outputUnspecified or false + then pkg.${output} or pkg.out or pkg + else pkg; + + getBin = getOutput "bin"; + getLib = getOutput "lib"; + getDev = getOutput "dev"; /*** deprecated stuff ***/ diff --git a/lib/strings.nix b/lib/strings.nix index bda96fb32da02..9e9bdd6e1535f 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -88,15 +88,14 @@ rec { makeSearchPath = subDir: packages: concatStringsSep ":" (map (path: path + "/" + subDir) packages); - /* Construct a Unix-style search path, given trying outputs in order. + /* Construct a Unix-style search path, using given package output. 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" + makeSearchPathOutput "dev" "bin" [ pkgs.openssl pkgs.zlib ] + => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev/bin:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/bin" */ - makeSearchPathOutputs = subDir: outputs: pkgs: - makeSearchPath subDir (map (pkg: if pkg.outputUnspecified or false then lib.tryAttrs (outputs ++ ["out"]) pkg else pkg) pkgs); + makeSearchPathOutput = output: subDir: pkgs: makeSearchPath subDir (map (lib.getOutput output) pkgs); /* Construct a library search path (such as RPATH) containing the libraries for a set of packages @@ -108,9 +107,7 @@ rec { makeLibraryPath [ pkgs.openssl pkgs.zlib ] => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r/lib:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/lib" */ - makeLibraryPath = pkgs: makeSearchPath "lib" - # try to guess the right output of each pkg - (map (pkg: if pkg.outputUnspecified or false then pkg.lib or (pkg.out or pkg) else pkg) pkgs); + makeLibraryPath = makeSearchPathOutput "lib" "lib"; /* Construct a binary search path (such as $PATH) containing the binaries for a set of packages. @@ -119,8 +116,7 @@ rec { makeBinPath ["/root" "/usr" "/usr/local"] => "/root/bin:/usr/bin:/usr/local/bin" */ - makeBinPath = pkgs: makeSearchPath "bin" - (map (pkg: if pkg.outputUnspecified or false then pkg.bin or (pkg.out or pkg) else pkg) pkgs); + makeBinPath = makeSearchPathOutput "bin" "bin"; /* Construct a perl search path (such as $PERL5LIB) @@ -132,8 +128,7 @@ rec { makePerlPath [ pkgs.perlPackages.NetSMTP ] => "/nix/store/n0m1fk9c960d8wlrs62sncnadygqqc6y-perl-Net-SMTP-1.25/lib/perl5/site_perl" */ - makePerlPath = pkgs: makeSearchPath "lib/perl5/site_perl" - (map (pkg: if pkg.outputUnspecified or false then pkg.lib or (pkg.out or pkg) else pkg) pkgs); + makePerlPath = makeSearchPathOutput "lib" "lib/perl5/site_perl"; /* Dependening on the boolean `cond', return either the given string or the empty string. Useful to contatenate against a bigger string. |