nixos systemPackages: rework default outputs

- Now `pkg.outputUnspecified = true` but this attribute is missing in
every output, so we can recognize whether the user chose or not.
If (s)he didn't choose, we put `pkg.bin or pkg.out or pkg` into
`systemPackages`.
- `outputsToLink` is replaced by `extraOutputsToLink`.
We add extra outputs *regardless* of whether the user chose anything.
It's mainly meant for outputs with docs and debug symbols.
- Note that as a result, some libraries will disappear from system path.

Changed files
+21 -15
lib
nixos
modules
pkgs
build-support
buildenv
+1 -1
lib/customisation.nix
···
};
outputsList = map outputToAttrListElement outputs;
-
in commonAttrs.${drv.outputName};
+
in commonAttrs // { outputUnspecified = true; };
/* Strip a derivation of all non-essential attributes, returning
+1 -1
nixos/modules/config/debug-info.nix
···
# environment.pathsToLink, and we can't have both.
#environment.pathsToLink = [ "/lib/debug/.build-id" ];
-
environment.outputsToLink =
+
environment.extraOutputsToLink =
optional config.environment.enableDebugInfo "debug";
};
+9 -10
nixos/modules/config/system-path.nix
···
description = "List of directories to be symlinked in <filename>/run/current-system/sw</filename>.";
};
-
outputsToLink = mkOption {
+
extraOutputsToLink = 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>.";
};
};
···
"/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;
+
# 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;
+
inherit (config.environment) pathsToLink extraOutputsToLink;
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
+1 -1
nixos/modules/programs/man.nix
···
environment.pathsToLink = [ "/share/man" ];
-
environment.outputsToLink = [ "man" ];
+
environment.extraOutputsToLink = [ "man" ];
};
+1 -1
nixos/modules/security/polkit.nix
···
config = mkIf cfg.enable {
-
environment.systemPackages = [ pkgs.polkit ];
+
environment.systemPackages = [ pkgs.polkit.bin pkgs.polkit.out ];
systemd.packages = [ pkgs.polkit.out ];
+8 -1
pkgs/build-support/buildenv/default.nix
···
# directories in the list is not symlinked.
pathsToLink ? ["/"]
+
, # The package outputs to include. By default, only the default
+
# output is included.
+
extraOutputsToLink ? []
+
, # Root the result in directory "$out${extraPrefix}", e.g. "/share".
extraPrefix ? ""
···
runCommand name
rec { inherit manifest ignoreCollisions passthru meta pathsToLink extraPrefix postBuild buildInputs;
pkgs = builtins.toJSON (map (drv: {
-
paths = [ drv ];
+
paths =
+
[ drv ]
+
++ lib.filter (p: p!=null)
+
(builtins.map (outName: drv.${outName} or null) extraOutputsToLink);
priority = drv.meta.priority or 5;
}) paths);
preferLocalBuild = true;