summary refs log tree commit diff
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-04-07 16:00:09 +0200
committerVladimír Čunát <vcunat@gmail.com>2016-04-07 16:00:09 +0200
commit710573ce6d3478e843ac4891d95185eadba6bd5e (patch)
treeb044be2f760e82dd19977fc40500541b52d93c1c
parentd1df28f8e5b98be01417ffc1032020415390f2a0 (diff)
parent9a824f2f1dd01450e6f7270246f77210d4c9c2a5 (diff)
downloadnixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.tar
nixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.tar.gz
nixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.tar.bz2
nixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.tar.lz
nixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.tar.xz
nixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.tar.zst
nixpkgs-710573ce6d3478e843ac4891d95185eadba6bd5e.zip
Merge #12653: rework default outputs
-rw-r--r--lib/customisation.nix2
-rw-r--r--nixos/modules/config/debug-info.nix2
-rw-r--r--nixos/modules/config/system-path.nix17
-rw-r--r--nixos/modules/programs/man.nix2
-rw-r--r--nixos/modules/security/polkit.nix2
-rw-r--r--pkgs/build-support/buildenv/default.nix14
-rw-r--r--pkgs/stdenv/generic/default.nix25
7 files changed, 42 insertions, 22 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 585495469b2..efe82d78660 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -129,7 +129,7 @@ rec {
         };
 
       outputsList = map outputToAttrListElement outputs;
-  in commonAttrs.${drv.outputName};
+  in commonAttrs // { outputUnspecified = true; };
 
 
   /* Strip a derivation of all non-essential attributes, returning
diff --git a/nixos/modules/config/debug-info.nix b/nixos/modules/config/debug-info.nix
index a096a9809ce..17cb862d291 100644
--- a/nixos/modules/config/debug-info.nix
+++ b/nixos/modules/config/debug-info.nix
@@ -38,7 +38,7 @@ with lib;
     # environment.pathsToLink, and we can't have both.
     #environment.pathsToLink = [ "/lib/debug/.build-id" ];
 
-    environment.outputsToLink =
+    environment.extraOutputsToInstall =
       optional config.environment.enableDebugInfo "debug";
 
   };
diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix
index 3df7d7cdac4..d7815324c4c 100644
--- a/nixos/modules/config/system-path.nix
+++ b/nixos/modules/config/system-path.nix
@@ -73,11 +73,11 @@ in
         description = "List of directories to be symlinked in <filename>/run/current-system/sw</filename>.";
       };
 
-      outputsToLink = mkOption {
+      extraOutputsToInstall = mkOption {
         type = types.listOf types.str;
         default = [ ];
-        example = [ "doc" ];
-        description = "List of package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
+        example = [ "doc" "info" "docdev" ];
+        description = "List of additional package outputs to be symlinked into <filename>/run/current-system/sw</filename>.";
       };
 
     };
@@ -120,18 +120,13 @@ in
         "/share/vim-plugins"
       ];
 
-    environment.outputsToLink = [ "bin" "lib" "out" ];
-
     system.path = pkgs.buildEnv {
       name = "system-path";
-      paths =
-        lib.filter (drv: drv != null && drv != (drv.dev or null))
-          (lib.concatMap (drv:
-            [ drv ] ++ map (outputName: drv.${outputName}.outPath or null) config.environment.outputsToLink)
-           config.environment.systemPackages);
-      inherit (config.environment) pathsToLink;
+      paths = config.environment.systemPackages;
+      inherit (config.environment) pathsToLink extraOutputsToInstall;
       ignoreCollisions = true;
       # !!! Hacky, should modularise.
+      # outputs TODO: note that the tools will often not be linked by default
       postBuild =
         ''
           if [ -x $out/bin/update-mime-database -a -w $out/share/mime ]; then
diff --git a/nixos/modules/programs/man.nix b/nixos/modules/programs/man.nix
index b2850653804..201144ccb45 100644
--- a/nixos/modules/programs/man.nix
+++ b/nixos/modules/programs/man.nix
@@ -23,7 +23,7 @@ with lib;
 
     environment.pathsToLink = [ "/share/man" ];
 
-    environment.outputsToLink = [ "man" ];
+    environment.extraOutputsToInstall = [ "man" ];
 
   };
 
diff --git a/nixos/modules/security/polkit.nix b/nixos/modules/security/polkit.nix
index 70e5e8b9fa7..507f81bbf07 100644
--- a/nixos/modules/security/polkit.nix
+++ b/nixos/modules/security/polkit.nix
@@ -59,7 +59,7 @@ in
 
   config = mkIf cfg.enable {
 
-    environment.systemPackages = [ pkgs.polkit ];
+    environment.systemPackages = [ pkgs.polkit.bin pkgs.polkit.out ];
 
     systemd.packages = [ pkgs.polkit.out ];
 
diff --git a/pkgs/build-support/buildenv/default.nix b/pkgs/build-support/buildenv/default.nix
index 5de02c8ed25..8b2167a8e74 100644
--- a/pkgs/build-support/buildenv/default.nix
+++ b/pkgs/build-support/buildenv/default.nix
@@ -25,6 +25,10 @@
   # directories in the list is not symlinked.
   pathsToLink ? ["/"]
 
+, # The package outputs to include. By default, only the default
+  # output is included.
+  extraOutputsToInstall ? []
+
 , # Root the result in directory "$out${extraPrefix}", e.g. "/share".
   extraPrefix ? ""
 
@@ -43,7 +47,15 @@ runCommand name
     inherit manifest ignoreCollisions checkCollisionContents passthru
             meta pathsToLink extraPrefix postBuild buildInputs;
     pkgs = builtins.toJSON (map (drv: {
-      paths = [ drv ];
+      paths =
+        # 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) extraOutputsToInstall);
       priority = drv.meta.priority or 5;
     }) paths);
     preferLocalBuild = true;
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index 8395394f5a8..547541d2824 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -220,12 +220,25 @@ 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`.
+            #   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
+              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