Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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, substituteAll }: 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 40, nativeBuildInputs ? [] # Handy e.g. if using makeWrapper in `postBuild`. 41, buildInputs ? [] 42 43, passthru ? {} 44, meta ? {} 45}: 46 47let 48 builder = substituteAll { 49 src = ./builder.pl; 50 inherit (builtins) storeDir; 51 }; 52in 53 54runCommand name 55 rec { 56 inherit manifest ignoreCollisions checkCollisionContents passthru 57 meta pathsToLink extraPrefix postBuild 58 nativeBuildInputs buildInputs; 59 pkgs = builtins.toJSON (map (drv: { 60 paths = 61 # First add the usual output(s): respect if user has chosen explicitly, 62 # and otherwise use `meta.outputsToInstall`. The attribute is guaranteed 63 # to exist in mkDerivation-created cases. The other cases (e.g. runCommand) 64 # aren't expected to have multiple outputs. 65 (if (! drv ? outputSpecified || ! drv.outputSpecified) 66 && drv.meta.outputsToInstall or null != null 67 then map (outName: drv.${outName}) drv.meta.outputsToInstall 68 else [ drv ]) 69 # Add any extra outputs specified by the caller of `buildEnv`. 70 ++ lib.filter (p: p!=null) 71 (builtins.map (outName: drv.${outName} or null) extraOutputsToInstall); 72 priority = drv.meta.priority or 5; 73 }) paths); 74 preferLocalBuild = true; 75 allowSubstitutes = false; 76 # XXX: The size is somewhat arbitrary 77 passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ]; 78 } 79 '' 80 ${buildPackages.perl}/bin/perl -w ${builder} 81 eval "$postBuild" 82 '')