From 3342f717da7f660b4695f09034abc175a14fda24 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Mon, 14 Mar 2016 11:56:03 +0100 Subject: stdenv: set meta.outputsToInstall unless overridden --- pkgs/stdenv/generic/default.nix | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'pkgs/stdenv/generic') diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 8395394f5a873..90cacd036c2a3 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -220,12 +220,22 @@ let # The meta attribute is passed in the resulting attribute set, # but it's not part of the actual derivation, i.e., it's not # passed to the builder and is not a dependency. But since we - # include it in the result, it *is* available to nix-env for - # queries. We also a meta.position attribute here to - # identify the source location of the package. - meta = meta // (if pos' != null then { - position = pos'.file + ":" + toString pos'.line; - } else {}); + # include it in the result, it *is* available to nix-env for queries. + meta = { } + # If the packager hasn't specified `outputsToInstall`, choose a default, + # namely `p.bin or p.out or p`; + # if he has specified it, it will be overridden below in `// meta`. + // { outputsToInstall = + let + outs = outputs'; # the value passed to derivation primitive + hasOutput = out: builtins.elem out outs; + in [( lib.findFirst hasOutput null (["bin" "out"] ++ outs) )]; + } + // meta + # Fill `meta.position` to identify the source location of the package. + // lib.optionalAttrs (pos' != null) + { position = pos'.file + ":" + toString pos'.line; } + ; inherit passthru; } // # Pass through extra attributes that are not inputs, but -- cgit 1.4.1 From 2995439003a6473fc6531d09900e183b0d5de425 Mon Sep 17 00:00:00 2001 From: Vladimír Čunát Date: Mon, 14 Mar 2016 12:15:58 +0100 Subject: buildEnv: respect meta.outputsToInstall As a result `systemPackages` now also respect it. Only nix-env remains and that has a PR filed: https://github.com/NixOS/nix/pull/815 --- nixos/modules/config/system-path.nix | 6 +----- pkgs/build-support/buildenv/default.nix | 7 ++++++- pkgs/stdenv/generic/default.nix | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'pkgs/stdenv/generic') diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index eb5eba7a042fe..69830683d9c5e 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -122,11 +122,7 @@ in system.path = pkgs.buildEnv { name = "system-path"; - paths = - # The default output probably shouldn't be globally configurable. - # Services and users should specify them explicitly unless they want this default. - map (p: if p.outputUnspecified or false then p.bin or p.out or p else p) - config.environment.systemPackages; + paths = config.environment.systemPackages; inherit (config.environment) pathsToLink extraOutputsToLink; ignoreCollisions = true; # !!! Hacky, should modularise. diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix index 8b8c3e3cbc205..10f7c69c3aa1a 100644 --- a/pkgs/build-support/buildenv/default.nix +++ b/pkgs/build-support/buildenv/default.nix @@ -48,7 +48,12 @@ runCommand name meta pathsToLink extraPrefix postBuild buildInputs; pkgs = builtins.toJSON (map (drv: { paths = - [ drv ] + # First add the usual output(s): respect if user has chosen explicitly, + # and otherwise use `meta.outputsToInstall` (guaranteed to exist by stdenv). + (if (drv.outputUnspecified or false) + then map (outName: drv.${outName}) drv.meta.outputsToInstall + else [ drv ]) + # Add any extra outputs specified by the caller of `buildEnv`. ++ lib.filter (p: p!=null) (builtins.map (outName: drv.${outName} or null) extraOutputsToLink); priority = drv.meta.priority or 5; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 90cacd036c2a3..547541d28246e 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -225,6 +225,9 @@ let # If the packager hasn't specified `outputsToInstall`, choose a default, # namely `p.bin or p.out or p`; # if he has specified it, it will be overridden below in `// meta`. + # Note: This default probably shouldn't be globally configurable. + # Services and users should specify outputs explicitly, + # unless they are comfortable with this default. // { outputsToInstall = let outs = outputs'; # the value passed to derivation primitive -- cgit 1.4.1