Further changes

This commit is contained in:
Jacek Galowicz 2023-12-01 11:25:22 +00:00
parent f55ee7cf77
commit eff9b12bc2
4 changed files with 108 additions and 136 deletions

View file

@ -1,8 +1,8 @@
{ runCommand { runCommand
, version
, system , system
, nix , buildPackages
, cacert , cacert
, nix
}: }:
let let
@ -11,6 +11,8 @@ let
rootPaths = [ nix cacert ]; rootPaths = [ nix cacert ];
}; };
inherit (nix) version;
env = { env = {
meta.description = "Distribution-independent Nix bootstrap binaries for ${system}"; meta.description = "Distribution-independent Nix bootstrap binaries for ${system}";
}; };

35
coverage.nix Normal file
View file

@ -0,0 +1,35 @@
{ lib
, releaseTools
, nix
, stdenv
}:
let
inherit (nix) version;
in
releaseTools.coverageAnalysis {
name = "nix-coverage-${version}";
inherit (nix)
src
configureFlags
nativeBuildInputs
buildInputs
#checkInputs
;
enableParallelBuilding = true;
dontInstall = false;
doInstallCheck = true;
installCheckTarget = "installcheck"; # work around buggy detection in stdenv
lcovFilter = [ "*/boost/*" "*-tab.*" ];
hardeningDisable = ["fortify"];
NIX_CFLAGS_COMPILE = "-DCOVERAGE=1";
}

115
flake.nix
View file

@ -479,60 +479,25 @@
dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage); dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage);
# Line coverage analysis. # Line coverage analysis.
coverage = coverage = nixpkgsFor.x86_64-linux.native.callPackage ./coverage.nix {};
with nixpkgsFor.x86_64-linux.native;
with commonDeps { inherit pkgs; };
releaseTools.coverageAnalysis {
name = "nix-coverage-${version}";
src = nixSrc;
configureFlags = testConfigureFlags;
enableParallelBuilding = true;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps ++ checkDeps;
dontInstall = false;
doInstallCheck = true;
installCheckTarget = "installcheck"; # work around buggy detection in stdenv
lcovFilter = [ "*/boost/*" "*-tab.*" ];
hardeningDisable = ["fortify"];
NIX_CFLAGS_COMPILE = "-DCOVERAGE=1";
};
# API docs for Nix's unstable internal C++ interfaces. # API docs for Nix's unstable internal C++ interfaces.
internal-api-docs = internal-api-docs = nixpkgsFor.x86_64-linux.native.nix.overrideAttrs (old: {
with nixpkgsFor.x86_64-linux.native; pname = "nix-internal-api-docs";
with commonDeps { inherit pkgs; };
stdenv.mkDerivation { configureFlags = old.configureFlags ++ [ "--enable-internal-api-docs" ];
pname = "nix-internal-api-docs"; nativeBuildInputs = old.nativeBuildInputs ++ [ nixpkgsFor.x86_64-linux.native.doxygen ];
inherit version;
src = nixSrc; dontBuild = true;
doCheck = false;
configureFlags = testConfigureFlags ++ internalApiDocsConfigureFlags; installTargets = [ "internal-api-html" ];
nativeBuildInputs = nativeBuildDeps; postInstall = ''
buildInputs = buildDeps ++ propagatedDeps mkdir -p $out/nix-support
++ awsDeps ++ checkDeps ++ internalApiDocsDeps; echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> $out/nix-support/hydra-build-products
'';
dontBuild = true; });
installTargets = [ "internal-api-html" ];
postInstall = ''
mkdir -p $out/nix-support
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> $out/nix-support/hydra-build-products
'';
};
# System tests. # System tests.
tests = import ./tests/nixos { inherit lib nixpkgs nixpkgsFor; } // { tests = import ./tests/nixos { inherit lib nixpkgs nixpkgsFor; } // {
@ -540,7 +505,9 @@
# Make sure that nix-env still produces the exact same result # Make sure that nix-env still produces the exact same result
# on a particular version of Nixpkgs. # on a particular version of Nixpkgs.
evalNixpkgs = evalNixpkgs =
with nixpkgsFor.x86_64-linux.native; let
inherit (nixpkgsFor.x86_64-linux.native) runCommand nix nixpkgs-regression;
in
runCommand "eval-nixos" { buildInputs = [ nix ]; } runCommand "eval-nixos" { buildInputs = [ nix ]; }
'' ''
type -p nix-env type -p nix-env
@ -627,47 +594,17 @@
stdenvs))); stdenvs)));
devShells = let devShells = let
makeShell = pkgs: stdenv: makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; }).overrideAttrs (_: {
let installFlags = "sysconfdir=$(out)/etc";
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform; shellHook = ''
in PATH=$prefix/bin:$PATH
with commonDeps { inherit pkgs; }; unset PYTHONPATH
stdenv.mkDerivation { export MANPATH=$out/share/man:$MANPATH
name = "nix";
outputs = [ "out" "dev" "doc" ] # Make bash completion work.
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "check"; XDG_DATA_DIRS+=:$out/share
'';
nativeBuildInputs = nativeBuildDeps });
++ lib.optional stdenv.cc.isClang pkgs.buildPackages.bear
++ lib.optional
(stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform)
pkgs.buildPackages.clang-tools
# We want changelog-d in the shell even if the current build doesn't need it
++ lib.optional (officialRelease || ! buildUnreleasedNotes) changelog-d
;
buildInputs = buildDeps ++ propagatedDeps
++ awsDeps ++ checkDeps ++ internalApiDocsDeps;
configureFlags = configureFlags
++ testConfigureFlags ++ internalApiDocsConfigureFlags
++ lib.optional (!canRunInstalled) "--disable-doc-gen";
enableParallelBuilding = true;
installFlags = "sysconfdir=$(out)/etc";
shellHook =
''
PATH=$prefix/bin:$PATH
unset PYTHONPATH
export MANPATH=$out/share/man:$MANPATH
# Make bash completion work.
XDG_DATA_DIRS+=:$out/share
'';
};
in in
forAllSystems (system: forAllSystems (system:
let let

View file

@ -41,16 +41,12 @@
}: }:
let let
version = lib.fileContents ./.version + versionSuffix; version = lib.fileContents ./.version + versionSuffix;
inherit (stdenv.hostPlatform) isStatic;
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform; canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
in in
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
name = "nix-${version}"; pname = "nix";
inherit version; inherit version;
src = src =
@ -103,17 +99,12 @@ stdenv.mkDerivation (finalAttrs: {
bison bison
flex flex
(lib.getBin lowdown) (lib.getBin lowdown)
jq # Also for custom mdBook preprocessor.
mdbook mdbook
mdbook-linkcheck mdbook-linkcheck
autoconf-archive autoconf-archive
autoreconfHook autoreconfHook
pkg-config pkg-config
# Tests
git
mercurial # FIXME: remove? only needed for tests
jq # Also for custom mdBook preprocessor.
openssh # only needed for tests (ssh-keygen)
] ]
++ lib.optional stdenv.hostPlatform.isLinux util-linux ++ lib.optional stdenv.hostPlatform.isLinux util-linux
# Official releases don't have rl-next, so we don't need to compile a changelog # Official releases don't have rl-next, so we don't need to compile a changelog
@ -133,19 +124,29 @@ stdenv.mkDerivation (finalAttrs: {
sqlite sqlite
xz xz
] ]
++ lib.optionals stdenv.isLinux [libseccomp] ++ lib.optional stdenv.isLinux libseccomp
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid ++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
# There have been issues building these dependencies # There have been issues building these dependencies
++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) (lib.optional (stdenv.isLinux || stdenv.isDarwin) ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin))
(aws-sdk-cpp.override { (aws-sdk-cpp.override {
apis = ["s3" "transfer"]; apis = ["s3" "transfer"];
customMemoryManagement = false; customMemoryManagement = false;
})) })
++ lib.optionals finalAttrs.doCheck [ ;
doCheck = true;
checkInputs = [
gtest gtest
rapidcheck rapidcheck
]; ];
nativeCheckInputs = [
git
mercurial # FIXME: remove? only needed for tests
openssh # only needed for tests (ssh-keygen)
];
propagatedBuildInputs = [ propagatedBuildInputs = [
boehmgc boehmgc
nlohmann_json nlohmann_json
@ -153,52 +154,49 @@ stdenv.mkDerivation (finalAttrs: {
disallowedReferences = [ boost ]; disallowedReferences = [ boost ];
preConfigure = lib.optionalString (! stdenv.hostPlatform.isStatic) preConfigure = lib.optionalString (! stdenv.hostPlatform.isStatic) ''
'' # Copy libboost_context so we don't get all of Boost in our closure.
# Copy libboost_context so we don't get all of Boost in our closure. # https://github.com/NixOS/nixpkgs/issues/45462
# https://github.com/NixOS/nixpkgs/issues/45462 mkdir -p $out/lib
mkdir -p $out/lib cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*,libboost_regex*} $out/lib
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*,libboost_regex*} $out/lib rm -f $out/lib/*.a
rm -f $out/lib/*.a ${lib.optionalString stdenv.hostPlatform.isLinux ''
${lib.optionalString stdenv.hostPlatform.isLinux '' chmod u+w $out/lib/*.so.*
chmod u+w $out/lib/*.so.* patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.* ''}
''} ${lib.optionalString stdenv.hostPlatform.isDarwin ''
${lib.optionalString stdenv.hostPlatform.isDarwin '' for LIB in $out/lib/*.dylib; do
for LIB in $out/lib/*.dylib; do chmod u+w $LIB
chmod u+w $LIB install_name_tool -id $LIB $LIB
install_name_tool -id $LIB $LIB install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true done
done install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib ''}
''} '';
'';
configureFlags = configureFlags =
lib.optionals stdenv.isLinux [ lib.optionals stdenv.isLinux [
"--with-boost=${boost}/lib" "--with-boost=${boost}/lib"
"--with-sandbox-shell=${sh}/bin/busybox" "--with-sandbox-shell=${sh}/bin/busybox"
] ]
++ lib.optionals (stdenv.isLinux && !(isStatic && stdenv.system == "aarch64-linux")) [ ++ lib.optional (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux"))
"LDFLAGS=-fuse-ld=gold" "LDFLAGS=-fuse-ld=gold"
]
++ [ "--sysconfdir=/etc" ] ++ [ "--sysconfdir=/etc" ]
++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" ++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell"
++ [ (lib.enableFeature finalAttrs.doCheck "tests") ] ++ [ (lib.enableFeature finalAttrs.doCheck "tests") ]
++ lib.optionals finalAttrs.doCheck ([ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ] ++ lib.optionals finalAttrs.doCheck (
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ [ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ]
"--enable-install-unit-tests" ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--with-check-bin-dir=${builtins.placeholder "check"}/bin" "--enable-install-unit-tests"
"--with-check-lib-dir=${builtins.placeholder "check"}/lib" "--with-check-bin-dir=${builtins.placeholder "check"}/bin"
]) "--with-check-lib-dir=${builtins.placeholder "check"}/lib"
])
++ lib.optional (!canRunInstalled) "--disable-doc-gen"; ++ lib.optional (!canRunInstalled) "--disable-doc-gen";
enableParallelBuilding = true; enableParallelBuilding = true;
makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1"; makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1";
doCheck = true;
installFlags = "sysconfdir=$(out)/etc"; installFlags = "sysconfdir=$(out)/etc";
postInstall = '' postInstall = ''