lol
1# buildEnv creates a tree of symlinks to the specified paths. This is
2# a fork of the buildEnv in the Nix distribution. Most changes should
3# eventually be merged back into the Nix distribution.
4
5{ buildPackages, runCommand, lib }:
6
7lib.makeOverridable
8({ name
9
10, # The manifest file (if any). A symlink $out/manifest will be
11 # created to it.
12 manifest ? ""
13
14, # The paths to symlink.
15 paths
16
17, # Whether to ignore collisions or abort.
18 ignoreCollisions ? false
19
20, # If there is a collision, check whether the contents and permissions match
21 # and only if not, throw a collision error.
22 checkCollisionContents ? true
23
24, # The paths (relative to each element of `paths') that we want to
25 # symlink (e.g., ["/bin"]). Any file not inside any of the
26 # directories in the list is not symlinked.
27 pathsToLink ? ["/"]
28
29, # The package outputs to include. By default, only the default
30 # output is included.
31 extraOutputsToInstall ? []
32
33, # Root the result in directory "$out${extraPrefix}", e.g. "/share".
34 extraPrefix ? ""
35
36, # Shell commands to run after building the symlink tree.
37 postBuild ? ""
38
39, # Additional inputs. Handy e.g. if using makeWrapper in `postBuild`.
40 buildInputs ? []
41
42, passthru ? {}
43, meta ? {}
44}:
45
46runCommand name
47 rec {
48 inherit manifest ignoreCollisions checkCollisionContents passthru
49 meta pathsToLink extraPrefix postBuild buildInputs;
50 pkgs = builtins.toJSON (map (drv: {
51 paths =
52 # First add the usual output(s): respect if user has chosen explicitly,
53 # and otherwise use `meta.outputsToInstall`. The attribute is guaranteed
54 # to exist in mkDerivation-created cases. The other cases (e.g. runCommand)
55 # aren't expected to have multiple outputs.
56 (if drv.outputUnspecified or false
57 && drv.meta.outputsToInstall or null != null
58 then map (outName: drv.${outName}) drv.meta.outputsToInstall
59 else [ drv ])
60 # Add any extra outputs specified by the caller of `buildEnv`.
61 ++ lib.filter (p: p!=null)
62 (builtins.map (outName: drv.${outName} or null) extraOutputsToInstall);
63 priority = drv.meta.priority or 5;
64 }) paths);
65 preferLocalBuild = true;
66 # XXX: The size is somewhat arbitrary
67 passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else null;
68 }
69 ''
70 ${buildPackages.perl}/bin/perl -w ${./builder.pl}
71 eval "$postBuild"
72 '')