From 7a1f4709cac3e23977df8d308ae2b0e7b8726b32 Mon Sep 17 00:00:00 2001 From: Tristan Ross Date: Thu, 7 May 2026 10:48:05 -0700 Subject: [PATCH] Readd missing attributes for static Darwin --- .github/workflows/build.yml | 2 +- flake.nix | 26 +++++++++++--------- packaging/dependencies.nix | 38 +++++++++++++++-------------- src/libutil/unix/file-descriptor.cc | 4 +++ 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c10c3ee00892..afcd1624df53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -81,7 +81,7 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/determinate-nix-action@main - uses: DeterminateSystems/flakehub-cache-action@main - - run: nix build .#packages.${{ inputs.system }}.nix-cli-static --no-link -L + - run: nix build .#packages.${{ inputs.system }}.nix-cli-static .#packages.${{ inputs.system }}.nix-cli-libcxxStdenv-static --no-link -L test: if: ${{ inputs.if && inputs.run_tests}} diff --git a/flake.nix b/flake.nix index 55ceca187523..80bb1b8402fa 100644 --- a/flake.nix +++ b/flake.nix @@ -461,21 +461,23 @@ supportsCross ? true, linuxOnly ? false, }: - lib.optionalAttrs (linuxOnly -> nixpkgsFor.${system}.native.stdenv.hostPlatform.isLinux) ( + lib.optionalAttrs (linuxOnly -> nixpkgsFor.${system}.native.stdenv.hostPlatform.isLinux) { + # These attributes go right into `packages.`. + "${pkgName}" = nixpkgsFor.${system}.native.nixComponents2.${pkgName}; + "${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents2.${pkgName}; + } + // flatMapAttrs (lib.genAttrs stdenvs (_: { })) ( + stdenvName: + { }: { # These attributes go right into `packages.`. - "${pkgName}" = nixpkgsFor.${system}.native.nixComponents2.${pkgName}; - "${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents2.${pkgName}; + "${pkgName}-${stdenvName}" = + nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents2.${pkgName}; + } + // lib.optionalAttrs supportsCross { + "${pkgName}-${stdenvName}-static" = + nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.pkgsStatic.nixComponents2.${pkgName}; } - // flatMapAttrs (lib.genAttrs stdenvs (_: { })) ( - stdenvName: - { }: - { - # These attributes go right into `packages.`. - "${pkgName}-${stdenvName}" = - nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents2.${pkgName}; - } - ) ) // lib.optionalAttrs supportsCross ( flatMapAttrs (lib.genAttrs crossSystems (_: { })) ( diff --git a/packaging/dependencies.nix b/packaging/dependencies.nix index c11c4149fa78..b8dbe22dfe2a 100644 --- a/packaging/dependencies.nix +++ b/packaging/dependencies.nix @@ -28,24 +28,26 @@ scope: { # small, run Nix with GC_PRINT_STATS=1 and look for messages # such as `Mark stack overflow`, `No room to copy back mark # stack`, and `Grew mark stack to ... frames`. - NIX_CFLAGS_COMPILE = [ - "-DINITIAL_MARK_STACK_SIZE=1048576" - ] - # For some reason that is not clear, it is wanting to use libgcc_eh which is not available. - # Force this to be built with compiler-rt & libunwind over libgcc_eh works. - # Issue: https://github.com/NixOS/nixpkgs/issues/177129 - ++ - lib.optionals - ( - stdenv.cc.isClang - && stdenv.hostPlatform.isStatic - && stdenv.cc.libcxx != null - && stdenv.cc.libcxx.isLLVM - ) - [ - "-rtlib=compiler-rt" - "-unwindlib=libunwind" - ]; + NIX_CFLAGS_COMPILE = builtins.toString ( + [ + "-DINITIAL_MARK_STACK_SIZE=1048576" + ] + # For some reason that is not clear, it is wanting to use libgcc_eh which is not available. + # Force this to be built with compiler-rt & libunwind over libgcc_eh works. + # Issue: https://github.com/NixOS/nixpkgs/issues/177129 + ++ + lib.optionals + ( + stdenv.cc.isClang + && stdenv.hostPlatform.isStatic + && stdenv.cc.libcxx != null + && stdenv.cc.libcxx.isLLVM + ) + [ + "-rtlib=compiler-rt" + "-unwindlib=libunwind" + ] + ); buildInputs = (attrs.buildInputs or [ ]) diff --git a/src/libutil/unix/file-descriptor.cc b/src/libutil/unix/file-descriptor.cc index 05ec38a67cc5..3b6ed656636f 100644 --- a/src/libutil/unix/file-descriptor.cc +++ b/src/libutil/unix/file-descriptor.cc @@ -7,6 +7,10 @@ #include #include +#if defined(__linux__) || defined(__FreeBSD__) +# include +#endif + #include "util-config-private.hh" #include "util-unix-config-private.hh"