Replace stdenv with stdenvNoCC to optimize CI workflows

This commit is contained in:
Qingsong Chen 2025-08-21 07:02:05 +00:00 committed by Tate, Hongliang Tian
parent 92f36751d0
commit 1e675d4387
6 changed files with 25 additions and 8 deletions

View File

@ -157,6 +157,17 @@ nix_gc:
@nix-collect-garbage -d
@nix-store --optimise
# This target is used to accelerate CI workflows, e.g., `benchmark_x86` and `benchmark_x86_tdx`.
initramfs_pkgs:
@nix-build \
nix/default.nix \
--tarball-ttl $(NIXPKGS_CACHE_TTL) \
$(NIX_QUIET) \
--argstr target x86_64 \
--arg enableBenchmark true \
--out-link /nix/var/nix/gcroots/auto/x86_64-initramfs-with-benchmark \
-A initramfs-image
$(EXT2_IMAGE):
@mkdir -p $(BUILD_DIR)
@dd if=/dev/zero of=$(EXT2_IMAGE) bs=2G count=1

View File

@ -1,4 +1,4 @@
{ lib, stdenv, callPackage, hostPlatform, pkgsHostTarget, }: rec {
{ lib, stdenvNoCC, callPackage, hostPlatform, pkgsHostTarget, }: rec {
# Use `--esx` flag to enable `CONFIG_NO_SHM` and disable `CONFIG_HAVE_TIMERFD_CREATE`.
fio = pkgsHostTarget.fio.overrideAttrs (_: { configureFlags = [ "--esx" ]; });
hackbench = callPackage ./hackbench.nix { };
@ -14,7 +14,7 @@
sqlite-speedtest1 = callPackage ./sqlite-speedtest1.nix { };
sysbench = if hostPlatform.isx86_64 then pkgsHostTarget.sysbench else null;
package = stdenv.mkDerivation {
package = stdenvNoCC.mkDerivation {
pname = "benchmark";
version = "0.1.0";
src = lib.fileset.toSource {

View File

@ -1,5 +1,5 @@
{ stdenv, pkgsBuildBuild, initramfs, compressed, }:
stdenv.mkDerivation {
{ stdenvNoCC, pkgsBuildBuild, initramfs, compressed, }:
stdenvNoCC.mkDerivation {
name = "initramfs-image";
nativeBuildInputs = with pkgsBuildBuild; [ cpio gzip ];
buildCommand = ''

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, hostPlatform, writeClosure, busybox, apps
{ lib, stdenvNoCC, fetchFromGitHub, hostPlatform, writeClosure, busybox, apps
, linux_vdso, benchmark, syscall, }:
let
etc = lib.fileset.toSource {
@ -13,7 +13,7 @@ let
++ lib.optionals (apps != null) [ apps.package ]
++ lib.optionals (benchmark != null) [ benchmark.package ]
++ lib.optionals (syscall != null) [ syscall.package ];
in stdenv.mkDerivation {
in stdenvNoCC.mkDerivation {
name = "initramfs";
buildCommand = ''
mkdir -p $out/{dev,etc,root,usr,opt,tmp,var,proc,sys}

View File

@ -1,4 +1,4 @@
{ lib, stdenv, callPackage, testSuite ? "ltp", workDir ? "/tmp", smp ? 1,
{ lib, stdenvNoCC, callPackage, testSuite ? "ltp", workDir ? "/tmp", smp ? 1,
}: rec {
inherit testSuite;
ltp = callPackage ./ltp.nix { };
@ -8,7 +8,7 @@
path = builtins.getEnv "GVISOR_PREBUILT_DIR";
};
package = stdenv.mkDerivation {
package = stdenvNoCC.mkDerivation {
pname = "syscall_test";
version = "0.1.0";
src = lib.fileset.toSource {

View File

@ -36,6 +36,12 @@ RUN make general_pkgs VERBOSE=0 \
&& make install_host_pkgs \
&& make nix_gc
# Build initramfs packages to accelerate CI workflows
#
# It could also cache `stdenvNoCC`, a fundamental and predefined build environment.
# Therefore, `make nix_gc` MUST NOT be run after this.
RUN make initramfs_pkgs VERBOSE=0
# Clean source files
RUN rm -rf /root/test