runCommand: Use stdenvNoCC

This ensures that most "trivial" derivations used to build NixOS
configurations no longer depend on GCC. For commands that do invoke
gcc, there is runCommandCC.
This commit is contained in:
Eelco Dolstra 2016-09-27 16:36:16 +02:00
parent 0cb16a6955
commit 97bfc2fac9
4 changed files with 17 additions and 9 deletions

View file

@ -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
}

View file

@ -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 -
'';

View file

@ -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.

View file

@ -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;