Commit eeabf857 authored by John Ericson's avatar John Ericson
Browse files

stdenvs: Distinguish between `extraBuildInputs` and `extraNativeBuildInputs`

Additionally, instead of pulling them from `setup.sh`, route them via
Nix. This gets us one step closer to making stdenv be a plain attribute
set instead of a derivation.
parent a71cf06b
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -59,11 +59,12 @@ in rec {
  stageFun = step: last: {shell             ? "${bootstrapTools}/bin/bash",
                          overrides         ? (self: super: {}),
                          extraPreHook      ? "",
                          extraNativeBuildInputs,
                          extraBuildInputs,
                          allowedRequisites ? null}:
    let
      thisStdenv = import ../generic {
        inherit config shell extraBuildInputs;
        inherit config shell extraNativeBuildInputs extraBuildInputs;
        allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [
          thisStdenv.cc.expand-response-params
        ];
@@ -162,6 +163,7 @@ in rec {

    };

    extraNativeBuildInputs = [];
    extraBuildInputs = [];
  };

@@ -169,6 +171,7 @@ in rec {

  stage1 = prevStage: with prevStage; stageFun 1 prevStage {
    extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
    extraNativeBuildInputs = [];
    extraBuildInputs = [ pkgs.libcxx ];

    allowedRequisites =
@@ -195,7 +198,8 @@ in rec {
      export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
    '';

    extraBuildInputs = with pkgs; [ xz darwin.CF libcxx ];
    extraNativeBuildInputs = [ pkgs.xz ];
    extraBuildInputs = with pkgs; [ darwin.CF libcxx ];

    allowedRequisites =
      [ bootstrapTools ] ++
@@ -226,7 +230,8 @@ in rec {
    # enables patchShebangs above. Unfortunately, patchShebangs ignores our $SHELL setting
    # and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and
    # patches our shebangs back to point at bootstrapTools. This makes sure bash comes first.
    extraBuildInputs = with pkgs; [ xz darwin.CF libcxx pkgs.bash ];
    extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ];
    extraBuildInputs = with pkgs; [ darwin.CF libcxx ];

    extraPreHook = ''
      export PATH=${pkgs.bash}/bin:$PATH
@@ -260,7 +265,8 @@ in rec {

  stage4 = prevStage: with prevStage; stageFun 4 prevStage {
    shell = "${pkgs.bash}/bin/bash";
    extraBuildInputs = with pkgs; [ xz darwin.CF libcxx pkgs.bash ];
    extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ];
    extraBuildInputs = with pkgs; [ darwin.CF libcxx ];
    extraPreHook = ''
      export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
    '';
@@ -321,6 +327,7 @@ in rec {
      libc = pkgs.darwin.Libsystem;
    };

    extraNativeBuildInputs = [];
    extraBuildInputs = with pkgs; [ darwin.CF libcxx ];

    extraAttrs = {
+8 −3
Original line number Diff line number Diff line
@@ -6,15 +6,20 @@ done

mkdir $out

# Buid the setup script
echo "export SHELL=$shell" > $out/setup
echo "initialPath=\"$initialPath\"" >> $out/setup
echo "defaultNativeBuildInputs=\"$defaultNativeBuildInputs\"" >> $out/setup
echo "$preHook" >> $out/setup
cat "$setup" >> $out/setup

# Allow the user to install stdenv using nix-env and get the packages
# in stdenv.
mkdir $out/nix-support
mkdir -p "$out/nix-support"
echo '# Hack to induce runtime dependencies on the default inputs' \
    > "$out/nix-support/default-inputs.txt"
printf '%s\n' $defaultNativeBuildInputs $defaultBuildInputs \
    >> "$out/nix-support/default-inputs.txt"
if [ "$propagatedUserEnvPkgs" ]; then
    printf '%s ' $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages
    printf '%s ' $propagatedUserEnvPkgs \
        > "$out/nix-support/propagated-user-env-packages"
fi
+13 −5
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ let lib = import ../../../lib; in lib.makeOverridable (

, setupScript ? ./setup.sh

, extraNativeBuildInputs ? []
, extraBuildInputs ? []
, __stdenvImpureHostDeps ? []
, __extraImpureHostDeps ? []
@@ -41,7 +42,7 @@ let lib = import ../../../lib; in lib.makeOverridable (
}:

let
  defaultNativeBuildInputs = extraBuildInputs ++
  defaultNativeBuildInputs = extraNativeBuildInputs ++
    [ ../../build-support/setup-hooks/move-docs.sh
      ../../build-support/setup-hooks/compress-man-pages.sh
      ../../build-support/setup-hooks/strip.sh
@@ -58,11 +59,16 @@ let
      cc
    ];

  defaultBuildInputs = extraBuildInputs;

  # The stdenv that we are producing.
  stdenv =
    derivation (
    (if isNull allowedRequisites then {} else { allowedRequisites = allowedRequisites ++ defaultNativeBuildInputs; }) //
    {
    lib.optionalAttrs (allowedRequisites != null) {
      allowedRequisites = allowedRequisites
        ++ defaultNativeBuildInputs ++ defaultBuildInputs;
    }
    // {
      inherit name;

      # Nix itself uses the `system` field of a derivation to decide where to
@@ -75,7 +81,8 @@ let

      setup = setupScript;

      inherit preHook initialPath shell defaultNativeBuildInputs;
      inherit preHook initialPath shell
        defaultNativeBuildInputs defaultBuildInputs;
    }
    // lib.optionalAttrs buildPlatform.isDarwin {
      __sandboxProfile = stdenvSandboxProfile;
@@ -91,7 +98,8 @@ let

      inherit buildPlatform hostPlatform targetPlatform;

      inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile;
      inherit extraNativeBuildInputs extraBuildInputs
        __extraImpureHostDeps extraSandboxProfile;

      # Utility flags to test the type of platform.
      inherit (hostPlatform)
+4 −4
Original line number Diff line number Diff line
@@ -44,10 +44,10 @@ rec {
    , ... } @ attrs:
    let
      dependencies = map lib.chooseDevOutputs [
        (map (drv: drv.nativeDrv or drv) nativeBuildInputs
        (map (drv: drv.nativeDrv or drv) (nativeBuildInputs ++ stdenv.defaultNativeBuildInputs)
           ++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh
           ++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh)
        (map (drv: drv.crossDrv or drv) buildInputs)
        (map (drv: drv.crossDrv or drv) (buildInputs ++ stdenv.defaultBuildInputs))
      ];
      propagatedDependencies = map lib.chooseDevOutputs [
        (map (drv: drv.nativeDrv or drv) propagatedNativeBuildInputs)
@@ -65,11 +65,11 @@ rec {
           "sandboxProfile" "propagatedSandboxProfile"])
        // (let
          computedSandboxProfile =
            lib.concatMap (input: input.__propagatedSandboxProfile or []) (stdenv.extraBuildInputs ++ lib.concatLists dependencies);
            lib.concatMap (input: input.__propagatedSandboxProfile or []) (lib.concatLists dependencies);
          computedPropagatedSandboxProfile =
            lib.concatMap (input: input.__propagatedSandboxProfile or []) (lib.concatLists propagatedDependencies);
          computedImpureHostDeps =
            lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (stdenv.extraBuildInputs ++ lib.concatLists dependencies));
            lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (lib.concatLists dependencies));
          computedPropagatedImpureHostDeps =
            lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (lib.concatLists propagatedDependencies));
        in
+2 −3
Original line number Diff line number Diff line
@@ -317,18 +317,17 @@ if [ -z "$crossConfig" ]; then
    # are handled identically to nativeBuildInputs
    declare -a nativePkgs
    for i in $nativeBuildInputs $buildInputs \
             $defaultNativeBuildInputs $defaultBuildInputs \
             $propagatedNativeBuildInputs $propagatedBuildInputs; do
        findInputs "$i" nativePkgs propagated-native-build-inputs
    done
else
    declare -a crossPkgs
    for i in $buildInputs $defaultBuildInputs $propagatedBuildInputs; do
    for i in $buildInputs $propagatedBuildInputs; do
        findInputs "$i" crossPkgs propagated-build-inputs
    done

    declare -a nativePkgs
    for i in $nativeBuildInputs $defaultNativeBuildInputs $propagatedNativeBuildInputs; do
    for i in $nativeBuildInputs $propagatedNativeBuildInputs; do
        findInputs "$i" nativePkgs propagated-native-build-inputs
    done
fi
Loading