diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 8d02cd81e0e..61def24efd8 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -34,7 +34,7 @@ let # copy what we need. Instead of using statically linked binaries, # we just copy what we need from Glibc and use patchelf to make it # work. - extraUtils = pkgs.runCommand "extra-utils" + extraUtils = pkgs.runCommandCC "extra-utils" { buildInputs = [pkgs.nukeReferences]; allowedReferences = [ "out" ]; # prevent accidents like glibc being included in the initrd } diff --git a/nixos/tests/boot-stage1.nix b/nixos/tests/boot-stage1.nix index ccd8394a1f0..e9087edb5d5 100644 --- a/nixos/tests/boot-stage1.nix +++ b/nixos/tests/boot-stage1.nix @@ -62,7 +62,7 @@ import ./make-test.nix ({ pkgs, ... }: { boot.initrd.kernelModules = [ "kcanary" ]; boot.initrd.extraUtilsCommands = let - compile = name: source: pkgs.runCommand name { inherit source; } '' + compile = name: source: pkgs.runCommandCC name { inherit source; } '' mkdir -p "$out/bin" echo "$source" | gcc -Wall -o "$out/bin/$name" -xc - ''; diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 398426bf9a4..d6f390ddfb1 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -1,15 +1,23 @@ -{ lib, stdenv, lndir }: +{ lib, stdenv, stdenvNoCC, lndir }: + +let + + runCommand' = stdenv: name: env: buildCommand: + stdenv.mkDerivation ({ + inherit name buildCommand; + passAsFile = [ "buildCommand" ]; + } // env); + +in rec { # Run the shell command `buildCommand' to produce a store path named # `name'. The attributes in `env' are added to the environment # prior to running the command. - runCommand = name: env: buildCommand: - stdenv.mkDerivation ({ - inherit name buildCommand; - passAsFile = [ "buildCommand" ]; - } // env); + runCommand = runCommandNoCC; + runCommandNoCC = runCommand' stdenvNoCC; + runCommandCC = runCommand' stdenv; # Create a single file. diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 87813571d9a..2eb7fb34b4d 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -82,7 +82,7 @@ let trivialBuilders = self: super: (import ../build-support/trivial-builders.nix { - inherit lib; inherit (self) stdenv; inherit (self.xorg) lndir; + inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; }); stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs;