From f58717bb0b6a86c0a8685dbf096649a6bffbcccf Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 6 Jun 2024 08:26:52 +0300 Subject: [PATCH 1/5] pkgsLinux: set crossSystem instead of localSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the doc implies, we should be using crossSystem to build *for* the Linux platform natively instead of hoping that the system has a remote builder or substituer with the right set of packages. While this could be considered a breaking change, pkgsLinux attribute is used exclusively for nixosTests and is a relatively new addition so there shouldn’t be many external users that would be affected by this change. --- pkgs/top-level/stage.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 087b43c3cb145..764f2b747afa9 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -249,7 +249,7 @@ let if stdenv.hostPlatform.isLinux then self else nixpkgsFun { - localSystem = lib.systems.elaborate "${stdenv.hostPlatform.parsed.cpu.name}-linux"; + crossSystem = lib.systems.elaborate "${stdenv.hostPlatform.parsed.cpu.name}-linux"; }; # Extend the package set with zero or more overlays. This preserves From c1b197dd5c92ffd2590917b3a87fd527b25252b5 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 6 Jun 2024 09:30:57 +0300 Subject: [PATCH 2/5] tpm2-tss: remove shadow dependency Fixes pkgsLinux.tpm2-tss build on macOS since shadow package is Linux-specific. --- .../libraries/tpm2-tss/default.nix | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/tpm2-tss/default.nix b/pkgs/development/libraries/tpm2-tss/default.nix index 354ab06d26b23..7d98ed89ce921 100644 --- a/pkgs/development/libraries/tpm2-tss/default.nix +++ b/pkgs/development/libraries/tpm2-tss/default.nix @@ -1,8 +1,8 @@ -{ stdenv, lib, fetchFromGitHub +{ stdenv, lib, fetchFromGitHub, runCommand , autoreconfHook, autoconf-archive, pkg-config, doxygen, perl , openssl, json_c, curl, libgcrypt , cmocka, uthash, ibm-sw-tpm2, iproute2, procps, which -, shadow, libuuid +, libuuid }: let # Avoid a circular dependency on Linux systems (systemd depends on tpm2-tss, @@ -11,6 +11,20 @@ let # might not support the withSystemd option. procpsWithoutSystemd = procps.override { withSystemd = false; }; procps_pkg = if stdenv.isLinux then procpsWithoutSystemd else procps; + + # Configure script expects tools from shadow but we are not actually using + # them. Instead of patching the build scripts, just add fake executables + # to native build inputs. These would fail the build if called from both POSIX + # shell and via native exec system call (albeit for different reasons). + # https://github.com/tpm2-software/tpm2-tss/blob/6c46325b466f35d40c2ed1043bfdfcfb8a367a34/configure.ac#L666-L675 + # https://github.com/tpm2-software/tpm2-tss/blob/6c46325b466f35d40c2ed1043bfdfcfb8a367a34/Makefile.am#L880-L898 + fakeShadow = runCommand "fake-shadow" { } '' + mkdir -p -- "$out"/bin + for executable in "$out"/bin/{useradd,groupadd}; do + printf '#!/bin/sh -\nexit 1' >"$executable" + chmod +x -- "$executable" + done + ''; in stdenv.mkDerivation rec { @@ -28,7 +42,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ autoreconfHook autoconf-archive pkg-config doxygen perl - shadow + fakeShadow ]; buildInputs = [ From ab8001f387a6ff416d2f685666e5eadd54d1e3e4 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 6 Jun 2024 18:01:54 +0300 Subject: [PATCH 3/5] procps: use systemdLibs instead of full systemd Fixes build on Darwin. --- pkgs/os-specific/linux/procps-ng/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/os-specific/linux/procps-ng/default.nix b/pkgs/os-specific/linux/procps-ng/default.nix index e4d245fdc7ce1..41dcc7902d2ac 100644 --- a/pkgs/os-specific/linux/procps-ng/default.nix +++ b/pkgs/os-specific/linux/procps-ng/default.nix @@ -7,8 +7,8 @@ # `ps` with systemd support is able to properly report different # attributes like unit name, so we want to have it on linux. -, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd -, systemd +, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemdLibs +, systemdLibs # procps is mostly Linux-only. Most commands require a running Linux # system (or very similar like that found in Cygwin). The one @@ -40,7 +40,7 @@ stdenv.mkDerivation rec { ]; buildInputs = [ ncurses ] - ++ lib.optional withSystemd systemd; + ++ lib.optional withSystemd systemdLibs; nativeBuildInputs = [ pkg-config ]; makeFlags = [ "usrbin_execdir=$(out)/bin" ] From 3106c3313987a50443bf035c1d7a40e626426971 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 6 Jun 2024 18:23:05 +0300 Subject: [PATCH 4/5] yodl: fix build on darwin --- pkgs/development/tools/misc/yodl/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/tools/misc/yodl/default.nix b/pkgs/development/tools/misc/yodl/default.nix index 2eee78c1c19c7..3d801d2a4a9f5 100644 --- a/pkgs/development/tools/misc/yodl/default.nix +++ b/pkgs/development/tools/misc/yodl/default.nix @@ -22,7 +22,9 @@ stdenv.mkDerivation rec { preConfigure = '' patchShebangs ./build patchShebangs scripts/ - substituteInPlace INSTALL.im --replace /usr $out + substituteInPlace INSTALL.im \ + --replace-fail /usr "$out" \ + --replace-fail 'COMPILER = "gcc";' "COMPILER = \"$CC\";" substituteInPlace macros/rawmacros/startdoc.pl --replace /usr/bin/perl ${perl}/bin/perl substituteInPlace scripts/yodl2whatever.in --replace getopt ${util-linux}/bin/getopt ''; @@ -47,6 +49,6 @@ stdenv.mkDerivation rec { homepage = "https://fbb-git.gitlab.io/yodl/"; license = licenses.gpl3; maintainers = with maintainers; [ pSub ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; } From 8ba1c3516eee98abd22a98703d7c2845213f5112 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Thu, 6 Jun 2024 18:25:32 +0300 Subject: [PATCH 5/5] icmake: allow building on darwin --- pkgs/development/tools/build-managers/icmake/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/tools/build-managers/icmake/default.nix b/pkgs/development/tools/build-managers/icmake/default.nix index 6320646974ad0..dd8fa28c952ca 100644 --- a/pkgs/development/tools/build-managers/icmake/default.nix +++ b/pkgs/development/tools/build-managers/icmake/default.nix @@ -41,6 +41,6 @@ stdenv.mkDerivation rec { homepage = "https://fbb-git.gitlab.io/icmake/"; license = licenses.gpl3; maintainers = with maintainers; [ pSub ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; }