Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
- uses: DeterminateSystems/flakehub-cache-action@main
- run: nix build .#packages.${{ inputs.system }}.default .#packages.${{ inputs.system }}.binaryTarball --no-link -L
- run: nix build .#packages.${{ inputs.system }}.binaryTarball --out-link tarball
- run: nix build .#packages.${{ inputs.system }}.nix-cli-static --no-link -L
- uses: actions/upload-artifact@v4
with:
name: ${{ inputs.system }}
Expand Down
1 change: 1 addition & 0 deletions doc/manual/source/development/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ For historic reasons and backward-compatibility, some CPU and OS identifiers are
|-----------------------------|-------------------------|---------------------|
| `x86` | | `i686` |
| `arm` | | `host_machine.cpu()`|
| `arm64` | | `host_machine.cpu()`|
| `ppc` | `little` | `powerpcle` |
| `ppc64` | `little` | `powerpc64le` |
| `ppc` | `big` | `powerpc` |
Expand Down
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@
"${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents2.${pkgName};
}
)
// {
"${pkgName}-static" = nixpkgsFor.${system}.native.pkgsStatic.nixComponents2.${pkgName};
}
)
// flatMapAttrs (lib.genAttrs stdenvs (_: { })) (
stdenvName:
Expand All @@ -479,6 +482,10 @@
"${pkgName}-${stdenvName}" =
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.nixComponents2.${pkgName};
}
// lib.optionalAttrs supportsCross {
"${pkgName}-${stdenvName}-static" =
nixpkgsFor.${system}.nativeForStdenv.${stdenvName}.pkgsStatic.nixComponents2.${pkgName};
}
)
)
// lib.optionalAttrs (builtins.elem system linux64BitSystems) {
Expand Down
9 changes: 9 additions & 0 deletions nix-meson-build-support/common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,14 @@ endif
# Darwin ld doesn't like "X.Y.ZpreABCD+W"
nix_soversion = meson.project_version().split('+')[0].split('pre')[0]

cxx = meson.get_compiler('cpp')

# Clang does not support prelinking on static builds
if cxx.get_id() == 'clang' and get_option('default_library') == 'static'
prelink = false
else
prelink = true
endif
Comment thread
coderabbitai[bot] marked this conversation as resolved.

subdir('assert-fail')
subdir('asan-options')
2 changes: 1 addition & 1 deletion nix-meson-build-support/default-system-cpu/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ if (host_machine.cpu_family() in [ 'ppc64', 'ppc' ]) and host_machine.endian() =
nix_system_cpu += 'le'
elif host_machine.cpu_family() in [ 'mips64', 'mips' ] and host_machine.endian() == 'little'
nix_system_cpu += 'el'
elif host_machine.cpu_family() == 'arm'
elif host_machine.cpu_family() in [ 'arm', 'arm64' ]
nix_system_cpu = host_machine.cpu()
endif
67 changes: 66 additions & 1 deletion packaging/dependencies.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,41 @@ in
scope: {
inherit stdenv;

libblake3 =
(pkgs.libblake3.override {
inherit stdenv;
# Nixpkgs disables tbb on static
useTBB = !stdenv.hostPlatform.isStatic;
})
# For some reason that is not clear, it is wanting to use libgcc_eh which is not available.
Comment thread
cole-h marked this conversation as resolved.
# Force this to be built with compiler-rt & libunwind over libgcc_eh works.
# Issue: https://github.com/NixOS/nixpkgs/issues/177129
.overrideAttrs
(
attrs:
lib.optionalAttrs
(
stdenv.cc.isClang
&& stdenv.hostPlatform.isStatic
&& stdenv.cc.libcxx != null
&& stdenv.cc.libcxx.isLLVM
)
{
NIX_CFLAGS_COMPILE = [
"-rtlib=compiler-rt"
"-unwindlib=libunwind"
];

buildInputs = [
pkgs.llvmPackages.libunwind
];
}
);

boehmgc =
(pkgs.boehmgc.override {
enableLargeConfig = true;
inherit stdenv;
}).overrideAttrs
(attrs: {
# Increase the initial mark stack size to avoid stack
Expand All @@ -27,7 +59,33 @@ 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";
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"
];

buildInputs =
(attrs.buildInputs or [ ])
++ lib.optional (
stdenv.cc.isClang
&& stdenv.hostPlatform.isStatic
&& stdenv.cc.libcxx != null
&& stdenv.cc.libcxx.isLLVM
) pkgs.llvmPackages.libunwind;
});

lowdown =
Expand Down Expand Up @@ -74,6 +132,7 @@ scope: {
"--with-thread"
];
enableIcu = false;
inherit stdenv;
}).overrideAttrs
(old: {
# Need to remove `--with-*` to use `--with-libraries=...`
Expand All @@ -82,4 +141,10 @@ scope: {
});

wasmtime = pkgs.callPackage ./wasmtime.nix { };

curl = pkgs.curl.override {
# libpsl uses a data file needed at runtime, not useful for nix.
pslSupport = !stdenv.hostPlatform.isStatic;
idnSupport = !stdenv.hostPlatform.isStatic;
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
2 changes: 1 addition & 1 deletion src/libcmd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
)
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
2 changes: 1 addition & 1 deletion src/libexpr-test-support/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ this_library = library(
# TODO: Remove `-lrapidcheck` when https://github.com/emil-e/rapidcheck/pull/326
# is available. See also ../libutil/build.meson
link_args : linker_export_flags + [ '-lrapidcheck' ],
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
22 changes: 18 additions & 4 deletions src/libexpr/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ project(
# TODO(Qyriad): increase the warning level
'warning_level=1',
'errorlogs=true', # Please print logs for tests that fail
'unity=on',
'unity_size=1024',
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
Expand Down Expand Up @@ -77,6 +79,17 @@ endif
# Used in public header. Affects ABI!
configdata_pub.set('NIX_USE_BOEHMGC', bdw_gc.found().to_int())

link_args = []

wasmtime_required = get_option('wasm').disable_if(
get_option('default_library') == 'static',
error_message : 'Building with wasmtime and static linking is not supported',
)

if wasmtime_required.enabled()
link_args += '-lwasmtime'
endif
Comment thread
cole-h marked this conversation as resolved.

toml11 = dependency(
'toml11',
version : '>=3.7.0',
Expand Down Expand Up @@ -156,14 +169,12 @@ sources = files(
'eval-cache.cc',
'eval-error.cc',
'eval-gc.cc',
'eval-profiler-settings.cc',
'eval-profiler.cc',
'eval-settings.cc',
'eval.cc',
'function-trace.cc',
'get-drvs.cc',
'json-to-value.cc',
'lexer-helpers.cc',
'nixexpr.cc',
'parallel-eval.cc',
'paths.cc',
Expand Down Expand Up @@ -216,6 +227,8 @@ parser_library = static_library(
'nixexpr-parser',
parser_tab,
lexer_tab,
# Putting eval-profiler-settings.cc here to work around an inscrutable gcc compiler error when doing a unity build.
files('eval-profiler-settings.cc', 'lexer-helpers.cc'),
cpp_args : parser_library_cpp_args,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
Expand All @@ -226,6 +239,7 @@ parser_library = static_library(
override_options : [
'b_ndebug=@0@'.format(not get_option('debug')),
'b_lto=@0@'.format(get_option('b_lto') and cxx.get_id() != 'gcc'),
'unity=off',
],
)

Expand All @@ -239,9 +253,9 @@ this_library = library(
soversion : nix_soversion,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags + [ '-lwasmtime' ],
link_args : linker_export_flags + link_args,
link_whole : [ parser_library ],
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
)
Expand Down
6 changes: 6 additions & 0 deletions src/libexpr/meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ option(
type : 'feature',
description : 'enable garbage collection in the Nix expression evaluator (requires Boehm GC)',
)

option(
'wasm',
type : 'feature',
description : 'enable wasmtime integration into the Nix expression evaluator',
)
21 changes: 19 additions & 2 deletions src/libexpr/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
# Temporarily disabled on Windows because the `GC_throw_bad_alloc`
# symbol is missing during linking.
enableGC ? !stdenv.hostPlatform.isWindows,

# Whether to use wasmtime for wasm integration in the Nix language evaluator
#
# Temporarily disabled when static linking due to Rust not compiling
enableWasm ? !stdenv.hostPlatform.isStatic,
}:

let
Expand Down Expand Up @@ -65,8 +70,8 @@ mkMesonLibrary (finalAttrs: {

buildInputs = [
toml11
wasmtime
];
]
++ lib.optional enableWasm wasmtime;

propagatedBuildInputs = [
nix-util
Expand All @@ -79,8 +84,20 @@ mkMesonLibrary (finalAttrs: {

mesonFlags = [
(lib.mesonEnable "gc" enableGC)
(lib.mesonEnable "wasm" enableWasm)
];

# Fixes a problem with the "nix-expr-libcxxStdenv-static" package output.
# 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 over libgcc_eh works.
# Issue: https://github.com/NixOS/nixpkgs/issues/177129
NIX_CFLAGS_COMPILE = lib.optional (
stdenv.cc.isClang
&& stdenv.hostPlatform.isStatic
&& stdenv.cc.libcxx != null
&& stdenv.cc.libcxx.isLLVM
) "-rtlib=compiler-rt";

meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
Expand Down
5 changes: 4 additions & 1 deletion src/libexpr/primops/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ sources += files(
'fetchMercurial.cc',
'fetchTree.cc',
'fromTOML.cc',
'wasm.cc',
)

if wasmtime_required.enabled()
sources += files('wasm.cc')
endif
2 changes: 1 addition & 1 deletion src/libfetchers-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
2 changes: 2 additions & 0 deletions src/libfetchers/include/nix/fetchers/input-cache.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include "nix/fetchers/fetchers.hh"

namespace nix::fetchers {
Expand Down
4 changes: 3 additions & 1 deletion src/libfetchers/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ project(
# TODO(Qyriad): increase the warning level
'warning_level=1',
'errorlogs=true', # Please print logs for tests that fail
'unity=on',
'unity_size=1024',
],
meson_version : '>= 1.1',
license : 'LGPL-2.1-or-later',
Expand Down Expand Up @@ -72,7 +74,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [],
)
Expand Down
2 changes: 1 addition & 1 deletion src/libflake-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
2 changes: 1 addition & 1 deletion src/libflake/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
2 changes: 1 addition & 1 deletion src/libmain-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
2 changes: 1 addition & 1 deletion src/libmain/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
2 changes: 1 addition & 1 deletion src/libstore-c/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ this_library = library(
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
prelink : true, # For C++ static initializers
prelink : prelink, # For C++ static initializers
install : true,
)

Expand Down
Loading