From 60df5bcff8e362ad99041080f7f6f4353f8bf4e6 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 6 Nov 2024 22:47:09 +0100 Subject: [PATCH 1/3] refact: Extract build-utils-meson/libatomic --- build-utils-meson/libatomic/meson.build | 8 ++++++++ src/libutil/meson.build | 9 +-------- 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 build-utils-meson/libatomic/meson.build diff --git a/build-utils-meson/libatomic/meson.build b/build-utils-meson/libatomic/meson.build new file mode 100644 index 00000000000..d16d2381764 --- /dev/null +++ b/build-utils-meson/libatomic/meson.build @@ -0,0 +1,8 @@ + +# Check if -latomic is needed +# This is needed for std::atomic on some platforms +# We did not manage to test this reliably on all platforms, so we hardcode +# it for now. +if host_machine.cpu_family() == 'arm' + deps_other += cxx.find_library('atomic') +endif diff --git a/src/libutil/meson.build b/src/libutil/meson.build index 61806120fbb..a6dc8639478 100644 --- a/src/libutil/meson.build +++ b/src/libutil/meson.build @@ -53,16 +53,9 @@ endforeach configdata.set('HAVE_DECL_AT_SYMLINK_NOFOLLOW', cxx.has_header_symbol('fcntl.h', 'AT_SYMLINK_NOFOLLOW').to_int()) +subdir('build-utils-meson/libatomic') subdir('build-utils-meson/threads') -# Check if -latomic is needed -# This is needed for std::atomic on some platforms -# We did not manage to test this reliably on all platforms, so we hardcode -# it for now. -if host_machine.cpu_family() == 'arm' - deps_other += cxx.find_library('atomic') -endif - if host_machine.system() == 'windows' socket = cxx.find_library('ws2_32') deps_other += socket From ec4204c774c39839553a103e49a59b58890e4ea3 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 6 Nov 2024 22:48:09 +0100 Subject: [PATCH 2/3] fix: Build nix-store on arm with libatomic --- src/libstore/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstore/meson.build b/src/libstore/meson.build index 1d5f949af11..101879e9090 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -81,6 +81,7 @@ if host_machine.system() == 'windows' deps_other += [wsock32] endif +subdir('build-utils-meson/libatomic') subdir('build-utils-meson/threads') boost = dependency( From 7f467ce96c437571986985612b8b95442fbd9f62 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 6 Nov 2024 22:49:04 +0100 Subject: [PATCH 3/3] fix: Add splicing to fix the manual in cross We *could* use a "native" manual instead - ie reusing a native `nixpkgsFor.${buildPlatform}`, but this works, and also works for possible cases where we have a custom or patched build tool. --- flake.nix | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/flake.nix b/flake.nix index 3ef027dd14e..3c8328a5220 100644 --- a/flake.nix +++ b/flake.nix @@ -124,18 +124,35 @@ # without "polluting" the top level "`pkgs`" attrset. # This also has the benefit of providing us with a distinct set of packages # we can iterate over. - nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix { - inherit (final) lib; - inherit officialRelease; - src = self; - }); + nixComponents = + lib.makeScopeWithSplicing' + { + inherit (final) splicePackages; + inherit (final.nixDependencies) newScope; + } + { + otherSplices = final.generateSplicesForMkScope "nixComponents"; + f = import ./packaging/components.nix { + inherit (final) lib; + inherit officialRelease; + src = self; + }; + }; # The dependencies are in their own scope, so that they don't have to be # in Nixpkgs top level `pkgs` or `nixComponents`. - nixDependencies = lib.makeScope final.newScope (import ./packaging/dependencies.nix { - inherit inputs stdenv; - pkgs = final; - }); + nixDependencies = lib.makeScopeWithSplicing' + { + inherit (final) splicePackages; + inherit (final) newScope; + } + { + otherSplices = final.generateSplicesForMkScope "nixDependencies"; + f = import ./packaging/dependencies.nix { + inherit inputs stdenv; + pkgs = final; + }; + }; nix = final.nixComponents.nix;