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";
}

View file

@ -479,52 +479,17 @@
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;
with commonDeps { inherit pkgs; };
stdenv.mkDerivation {
pname = "nix-internal-api-docs"; pname = "nix-internal-api-docs";
inherit version;
src = nixSrc; configureFlags = old.configureFlags ++ [ "--enable-internal-api-docs" ];
nativeBuildInputs = old.nativeBuildInputs ++ [ nixpkgsFor.x86_64-linux.native.doxygen ];
configureFlags = testConfigureFlags ++ internalApiDocsConfigureFlags;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps
++ awsDeps ++ checkDeps ++ internalApiDocsDeps;
dontBuild = true; dontBuild = true;
doCheck = false;
installTargets = [ "internal-api-html" ]; installTargets = [ "internal-api-html" ];
@ -532,7 +497,7 @@
mkdir -p $out/nix-support mkdir -p $out/nix-support
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> $out/nix-support/hydra-build-products 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,39 +594,9 @@
stdenvs))); stdenvs)));
devShells = let devShells = let
makeShell = pkgs: stdenv: makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; }).overrideAttrs (_: {
let
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
in
with commonDeps { inherit pkgs; };
stdenv.mkDerivation {
name = "nix";
outputs = [ "out" "dev" "doc" ]
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "check";
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"; installFlags = "sysconfdir=$(out)/etc";
shellHook = ''
shellHook =
''
PATH=$prefix/bin:$PATH PATH=$prefix/bin:$PATH
unset PYTHONPATH unset PYTHONPATH
export MANPATH=$out/share/man:$MANPATH export MANPATH=$out/share/man:$MANPATH
@ -667,7 +604,7 @@
# Make bash completion work. # Make bash completion work.
XDG_DATA_DIRS+=:$out/share 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,8 +154,7 @@ 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
@ -179,13 +179,13 @@ stdenv.mkDerivation (finalAttrs: {
"--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 (
[ "RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include" ]
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"--enable-install-unit-tests" "--enable-install-unit-tests"
"--with-check-bin-dir=${builtins.placeholder "check"}/bin" "--with-check-bin-dir=${builtins.placeholder "check"}/bin"
@ -197,8 +197,6 @@ stdenv.mkDerivation (finalAttrs: {
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 = ''