forked from lix-project/lix
Merge changes from topic "maint/flake-package.nix" into main
* changes: package: cleanup of all intermediaries package: migrate devShells package: migrate internal-api-docs package: migrate testNixVersions package: use pname, version, and dontBuild (first change with diff hash) package: refactor Nix out of flake.nix and into package.nix
This commit is contained in:
commit
f9701da8f6
419
flake.nix
419
flake.nix
|
@ -48,50 +48,6 @@
|
||||||
})
|
})
|
||||||
stdenvs);
|
stdenvs);
|
||||||
|
|
||||||
baseFiles =
|
|
||||||
# .gitignore has already been processed, so any changes in it are irrelevant
|
|
||||||
# at this point. It is not represented verbatim for test purposes because
|
|
||||||
# that would interfere with repo semantics.
|
|
||||||
fileset.fileFilter (f: f.name != ".gitignore") ./.;
|
|
||||||
|
|
||||||
configureFiles = fileset.unions [
|
|
||||||
./.version
|
|
||||||
./configure.ac
|
|
||||||
./m4
|
|
||||||
# TODO: do we really need README.md? It doesn't seem used in the build.
|
|
||||||
./README.md
|
|
||||||
];
|
|
||||||
|
|
||||||
topLevelBuildFiles = fileset.unions [
|
|
||||||
./local.mk
|
|
||||||
./Makefile
|
|
||||||
./Makefile.config.in
|
|
||||||
./mk
|
|
||||||
];
|
|
||||||
|
|
||||||
functionalTestFiles = fileset.unions [
|
|
||||||
./tests/functional
|
|
||||||
./tests/unit
|
|
||||||
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
|
|
||||||
];
|
|
||||||
|
|
||||||
nixSrc = fileset.toSource {
|
|
||||||
root = ./.;
|
|
||||||
fileset = fileset.intersection baseFiles (fileset.unions [
|
|
||||||
configureFiles
|
|
||||||
topLevelBuildFiles
|
|
||||||
./boehmgc-coroutine-sp-fallback.diff
|
|
||||||
./doc
|
|
||||||
./misc
|
|
||||||
./precompiled-headers.h
|
|
||||||
./src
|
|
||||||
./unit-test-data
|
|
||||||
./COPYING
|
|
||||||
./scripts/local.mk
|
|
||||||
functionalTestFiles
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
# Memoize nixpkgs for different platforms for efficiency.
|
# Memoize nixpkgs for different platforms for efficiency.
|
||||||
nixpkgsFor = forAllSystems
|
nixpkgsFor = forAllSystems
|
||||||
(system: let
|
(system: let
|
||||||
|
@ -118,120 +74,6 @@
|
||||||
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv");
|
cross = forAllCrossSystems (crossSystem: make-pkgs crossSystem "stdenv");
|
||||||
});
|
});
|
||||||
|
|
||||||
commonDeps =
|
|
||||||
{ pkgs
|
|
||||||
, isStatic ? pkgs.stdenv.hostPlatform.isStatic
|
|
||||||
}:
|
|
||||||
with pkgs; rec {
|
|
||||||
# Use "busybox-sandbox-shell" if present,
|
|
||||||
# if not (legacy) fallback and hope it's sufficient.
|
|
||||||
sh = pkgs.busybox-sandbox-shell or (busybox.override {
|
|
||||||
useMusl = true;
|
|
||||||
enableStatic = true;
|
|
||||||
enableMinimal = true;
|
|
||||||
extraConfig = ''
|
|
||||||
CONFIG_FEATURE_FANCY_ECHO y
|
|
||||||
CONFIG_FEATURE_SH_MATH y
|
|
||||||
CONFIG_FEATURE_SH_MATH_64 y
|
|
||||||
|
|
||||||
CONFIG_ASH y
|
|
||||||
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
|
|
||||||
|
|
||||||
CONFIG_ASH_ALIAS y
|
|
||||||
CONFIG_ASH_BASH_COMPAT y
|
|
||||||
CONFIG_ASH_CMDCMD y
|
|
||||||
CONFIG_ASH_ECHO y
|
|
||||||
CONFIG_ASH_GETOPTS y
|
|
||||||
CONFIG_ASH_INTERNAL_GLOB y
|
|
||||||
CONFIG_ASH_JOB_CONTROL y
|
|
||||||
CONFIG_ASH_PRINTF y
|
|
||||||
CONFIG_ASH_TEST y
|
|
||||||
'';
|
|
||||||
});
|
|
||||||
|
|
||||||
configureFlags =
|
|
||||||
lib.optionals stdenv.isLinux [
|
|
||||||
"--with-boost=${boost}/lib"
|
|
||||||
"--with-sandbox-shell=${sh}/bin/busybox"
|
|
||||||
]
|
|
||||||
++ lib.optionals (stdenv.isLinux && !(isStatic && stdenv.system == "aarch64-linux")) [
|
|
||||||
"LDFLAGS=-fuse-ld=gold"
|
|
||||||
];
|
|
||||||
|
|
||||||
testConfigureFlags = [
|
|
||||||
"RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include"
|
|
||||||
];
|
|
||||||
|
|
||||||
internalApiDocsConfigureFlags = [
|
|
||||||
"--enable-internal-api-docs"
|
|
||||||
];
|
|
||||||
|
|
||||||
changelog-d = pkgs.buildPackages.callPackage ./misc/changelog-d.nix { };
|
|
||||||
|
|
||||||
nativeBuildDeps =
|
|
||||||
[
|
|
||||||
buildPackages.bison
|
|
||||||
buildPackages.flex
|
|
||||||
(lib.getBin buildPackages.lowdown)
|
|
||||||
buildPackages.mdbook
|
|
||||||
buildPackages.mdbook-linkcheck
|
|
||||||
buildPackages.autoconf-archive
|
|
||||||
buildPackages.autoreconfHook
|
|
||||||
buildPackages.pkg-config
|
|
||||||
|
|
||||||
# Tests
|
|
||||||
buildPackages.git
|
|
||||||
buildPackages.mercurial # FIXME: remove? only needed for tests
|
|
||||||
buildPackages.jq # Also for custom mdBook preprocessor.
|
|
||||||
]
|
|
||||||
++ lib.optionals stdenv.hostPlatform.isLinux [(buildPackages.util-linuxMinimal or buildPackages.utillinuxMinimal)]
|
|
||||||
# Official releases don't have rl-next, so we don't need to compile a changelog
|
|
||||||
++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d
|
|
||||||
;
|
|
||||||
|
|
||||||
buildDeps =
|
|
||||||
[ curl
|
|
||||||
bzip2 xz brotli editline
|
|
||||||
openssl sqlite
|
|
||||||
libarchive
|
|
||||||
boost
|
|
||||||
lowdown
|
|
||||||
libsodium
|
|
||||||
]
|
|
||||||
++ lib.optionals stdenv.isLinux [libseccomp]
|
|
||||||
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid;
|
|
||||||
|
|
||||||
checkDeps = [
|
|
||||||
gtest
|
|
||||||
rapidcheck
|
|
||||||
];
|
|
||||||
|
|
||||||
internalApiDocsDeps = [
|
|
||||||
buildPackages.doxygen
|
|
||||||
];
|
|
||||||
|
|
||||||
awsDeps = lib.optional (stdenv.isLinux || stdenv.isDarwin)
|
|
||||||
(aws-sdk-cpp.override {
|
|
||||||
apis = ["s3" "transfer"];
|
|
||||||
customMemoryManagement = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
propagatedDeps =
|
|
||||||
[ ((boehmgc.override {
|
|
||||||
enableLargeConfig = true;
|
|
||||||
}).overrideAttrs(o: {
|
|
||||||
patches = (o.patches or []) ++ [
|
|
||||||
./boehmgc-coroutine-sp-fallback.diff
|
|
||||||
|
|
||||||
# https://github.com/ivmai/bdwgc/pull/586
|
|
||||||
./boehmgc-traceable_allocator-public.diff
|
|
||||||
];
|
|
||||||
})
|
|
||||||
)
|
|
||||||
nlohmann_json
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
installScriptFor = systems:
|
installScriptFor = systems:
|
||||||
with nixpkgsFor.x86_64-linux.native;
|
with nixpkgsFor.x86_64-linux.native;
|
||||||
runCommand "installer-script"
|
runCommand "installer-script"
|
||||||
|
@ -266,51 +108,40 @@
|
||||||
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
echo "file installer $out/install" >> $out/nix-support/hydra-build-products
|
||||||
'';
|
'';
|
||||||
|
|
||||||
testNixVersions = pkgs: client: daemon: with commonDeps { inherit pkgs; }; with pkgs.lib; pkgs.stdenv.mkDerivation {
|
testNixVersions = pkgs: client: daemon: let
|
||||||
|
nix = pkgs.callPackage ./package.nix {
|
||||||
|
pname =
|
||||||
|
"nix-tests"
|
||||||
|
+ lib.optionalString
|
||||||
|
(lib.versionAtLeast daemon.version "2.4pre20211005" &&
|
||||||
|
lib.versionAtLeast client.version "2.4pre20211005")
|
||||||
|
"-${client.version}-against-${daemon.version}";
|
||||||
|
|
||||||
|
inherit fileset;
|
||||||
|
};
|
||||||
|
in nix.overrideAttrs (prevAttrs: {
|
||||||
NIX_DAEMON_PACKAGE = daemon;
|
NIX_DAEMON_PACKAGE = daemon;
|
||||||
NIX_CLIENT_PACKAGE = client;
|
NIX_CLIENT_PACKAGE = client;
|
||||||
name =
|
|
||||||
"nix-tests"
|
|
||||||
+ optionalString
|
|
||||||
(versionAtLeast daemon.version "2.4pre20211005" &&
|
|
||||||
versionAtLeast client.version "2.4pre20211005")
|
|
||||||
"-${client.version}-against-${daemon.version}";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = fileset.toSource {
|
|
||||||
root = ./.;
|
|
||||||
fileset = fileset.intersection baseFiles (fileset.unions [
|
|
||||||
configureFiles
|
|
||||||
topLevelBuildFiles
|
|
||||||
functionalTestFiles
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
VERSION_SUFFIX = versionSuffix;
|
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildDeps;
|
|
||||||
buildInputs = buildDeps ++ awsDeps ++ checkDeps;
|
|
||||||
propagatedBuildInputs = propagatedDeps;
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
configureFlags =
|
|
||||||
testConfigureFlags # otherwise configure fails
|
|
||||||
++ [ "--disable-build" ];
|
|
||||||
dontBuild = true;
|
dontBuild = true;
|
||||||
doInstallCheck = true;
|
doInstallCheck = true;
|
||||||
|
|
||||||
|
configureFlags = prevAttrs.configureFlags ++ [
|
||||||
|
# We don't need the actual build here.
|
||||||
|
"--disable-build"
|
||||||
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installCheckPhase = (optionalString pkgs.stdenv.hostPlatform.isDarwin ''
|
installCheckPhase = lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
|
||||||
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
||||||
'') + ''
|
'' + ''
|
||||||
mkdir -p src/nix-channel
|
mkdir -p src/nix-channel
|
||||||
make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES
|
make installcheck -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES
|
||||||
'';
|
'';
|
||||||
};
|
});
|
||||||
|
|
||||||
binaryTarball = nix: pkgs:
|
binaryTarball = nix: pkgs:
|
||||||
let
|
let
|
||||||
|
@ -387,109 +218,60 @@
|
||||||
'';
|
'';
|
||||||
|
|
||||||
overlayFor = getStdenv: final: prev:
|
overlayFor = getStdenv: final: prev:
|
||||||
let currentStdenv = getStdenv final; in
|
let
|
||||||
{
|
currentStdenv = getStdenv final;
|
||||||
nixStable = prev.nix;
|
comDeps = with final; commonDeps {
|
||||||
|
|
||||||
nix =
|
|
||||||
with final;
|
|
||||||
with commonDeps {
|
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
inherit (currentStdenv.hostPlatform) isStatic;
|
inherit (currentStdenv.hostPlatform) isStatic;
|
||||||
};
|
};
|
||||||
let
|
in {
|
||||||
canRunInstalled = currentStdenv.buildPlatform.canExecute currentStdenv.hostPlatform;
|
nixStable = prev.nix;
|
||||||
in currentStdenv.mkDerivation (finalAttrs: {
|
|
||||||
name = "nix-${version}";
|
|
||||||
inherit version;
|
|
||||||
|
|
||||||
src = nixSrc;
|
# Forward from the previous stage as we don’t want it to pick the lowdown override
|
||||||
VERSION_SUFFIX = versionSuffix;
|
nixUnstable = prev.nixUnstable;
|
||||||
|
|
||||||
outputs = [ "out" "dev" "doc" ];
|
changelog-d = final.buildPackages.callPackage ./misc/changelog-d.nix { };
|
||||||
|
boehmgc-nix = (final.boehmgc.override {
|
||||||
|
enableLargeConfig = true;
|
||||||
|
}).overrideAttrs (o: {
|
||||||
|
patches = (o.patches or [ ]) ++ [
|
||||||
|
./boehmgc-coroutine-sp-fallback.diff
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildDeps;
|
# https://github.com/ivmai/bdwgc/pull/586
|
||||||
buildInputs = buildDeps
|
./boehmgc-traceable_allocator-public.diff
|
||||||
# There have been issues building these dependencies
|
];
|
||||||
++ lib.optionals (currentStdenv.hostPlatform == currentStdenv.buildPlatform) awsDeps
|
});
|
||||||
++ lib.optionals finalAttrs.doCheck checkDeps;
|
|
||||||
|
|
||||||
propagatedBuildInputs = propagatedDeps;
|
default-busybox-sandbox-shell = final.busybox.override {
|
||||||
|
useMusl = true;
|
||||||
|
enableStatic = true;
|
||||||
|
enableMinimal = true;
|
||||||
|
extraConfig = ''
|
||||||
|
CONFIG_FEATURE_FANCY_ECHO y
|
||||||
|
CONFIG_FEATURE_SH_MATH y
|
||||||
|
CONFIG_FEATURE_SH_MATH_64 y
|
||||||
|
|
||||||
disallowedReferences = [ boost ];
|
CONFIG_ASH y
|
||||||
|
CONFIG_ASH_OPTIMIZE_FOR_SIZE y
|
||||||
|
|
||||||
preConfigure = lib.optionalString (! currentStdenv.hostPlatform.isStatic)
|
CONFIG_ASH_ALIAS y
|
||||||
''
|
CONFIG_ASH_BASH_COMPAT y
|
||||||
# Copy libboost_context so we don't get all of Boost in our closure.
|
CONFIG_ASH_CMDCMD y
|
||||||
# https://github.com/NixOS/nixpkgs/issues/45462
|
CONFIG_ASH_ECHO y
|
||||||
mkdir -p $out/lib
|
CONFIG_ASH_GETOPTS y
|
||||||
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
|
CONFIG_ASH_INTERNAL_GLOB y
|
||||||
rm -f $out/lib/*.a
|
CONFIG_ASH_JOB_CONTROL y
|
||||||
${lib.optionalString currentStdenv.hostPlatform.isLinux ''
|
CONFIG_ASH_PRINTF y
|
||||||
chmod u+w $out/lib/*.so.*
|
CONFIG_ASH_TEST y
|
||||||
patchelf --set-rpath $out/lib:${currentStdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
|
|
||||||
''}
|
|
||||||
${lib.optionalString currentStdenv.hostPlatform.isDarwin ''
|
|
||||||
for LIB in $out/lib/*.dylib; do
|
|
||||||
chmod u+w $LIB
|
|
||||||
install_name_tool -id $LIB $LIB
|
|
||||||
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
|
|
||||||
done
|
|
||||||
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
|
|
||||||
''}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configureFlags = configureFlags ++
|
|
||||||
[ "--sysconfdir=/etc" ] ++
|
|
||||||
lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell" ++
|
|
||||||
[ (lib.enableFeature finalAttrs.doCheck "tests") ] ++
|
|
||||||
lib.optionals finalAttrs.doCheck testConfigureFlags ++
|
|
||||||
lib.optional (!canRunInstalled) "--disable-doc-gen";
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1";
|
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
installFlags = "sysconfdir=$(out)/etc";
|
|
||||||
|
|
||||||
postInstall = ''
|
|
||||||
mkdir -p $doc/nix-support
|
|
||||||
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
|
||||||
${lib.optionalString currentStdenv.hostPlatform.isStatic ''
|
|
||||||
mkdir -p $out/nix-support
|
|
||||||
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
|
||||||
''}
|
|
||||||
${lib.optionalString currentStdenv.isDarwin ''
|
|
||||||
install_name_tool \
|
|
||||||
-change ${boost}/lib/libboost_context.dylib \
|
|
||||||
$out/lib/libboost_context.dylib \
|
|
||||||
$out/lib/libnixutil.dylib
|
|
||||||
''}
|
|
||||||
'';
|
|
||||||
|
|
||||||
doInstallCheck = finalAttrs.doCheck;
|
|
||||||
installCheckFlags = "sysconfdir=$(out)/etc";
|
|
||||||
installCheckTarget = "installcheck"; # work around buggy detection in stdenv
|
|
||||||
|
|
||||||
preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
||||||
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
|
||||||
'';
|
|
||||||
|
|
||||||
separateDebugInfo = !currentStdenv.hostPlatform.isStatic;
|
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
|
||||||
|
|
||||||
passthru.perl-bindings = final.callPackage ./perl {
|
|
||||||
inherit fileset;
|
|
||||||
stdenv = currentStdenv;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
meta.platforms = lib.platforms.unix;
|
nix = final.callPackage ./package.nix {
|
||||||
});
|
inherit versionSuffix fileset;
|
||||||
|
stdenv = currentStdenv;
|
||||||
|
boehmgc = final.boehmgc-nix;
|
||||||
|
busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
@ -514,31 +296,25 @@
|
||||||
dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage);
|
dockerImage = lib.genAttrs linux64BitSystems (system: self.packages.${system}.dockerImage);
|
||||||
|
|
||||||
# API docs for Nix's unstable internal C++ interfaces.
|
# API docs for Nix's unstable internal C++ interfaces.
|
||||||
internal-api-docs =
|
internal-api-docs = let
|
||||||
with nixpkgsFor.x86_64-linux.native;
|
nixpkgs = nixpkgsFor.x86_64-linux.native;
|
||||||
with commonDeps { inherit pkgs; };
|
inherit (nixpkgs) pkgs;
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
nix = pkgs.callPackage ./package.nix {
|
||||||
pname = "nix-internal-api-docs";
|
inherit versionSuffix fileset officialRelease buildUnreleasedNotes;
|
||||||
inherit version;
|
inherit (pkgs) changelog-d;
|
||||||
|
internalApiDocs = true;
|
||||||
src = nixSrc;
|
boehmgc = pkgs.boehmgc-nix;
|
||||||
|
busybox-sandbox-shell = pkgs.busybox-sandbox-shell;
|
||||||
configureFlags = testConfigureFlags ++ internalApiDocsConfigureFlags;
|
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildDeps;
|
|
||||||
buildInputs = buildDeps ++ propagatedDeps
|
|
||||||
++ awsDeps ++ checkDeps ++ internalApiDocsDeps;
|
|
||||||
|
|
||||||
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
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
in
|
||||||
|
nix.overrideAttrs (prev: {
|
||||||
|
# This Hydra job is just for the internal API docs.
|
||||||
|
# We don't need the build artifacts here.
|
||||||
|
dontBuild = true;
|
||||||
|
doCheck = false;
|
||||||
|
doInstallCheck = false;
|
||||||
|
});
|
||||||
|
|
||||||
# System tests.
|
# System tests.
|
||||||
tests = import ./tests/nixos { inherit lib nixpkgs nixpkgsFor; } // {
|
tests = import ./tests/nixos { inherit lib nixpkgs nixpkgsFor; } // {
|
||||||
|
@ -588,7 +364,7 @@
|
||||||
rl-next =
|
rl-next =
|
||||||
let pkgs = nixpkgsFor.${system}.native;
|
let pkgs = nixpkgsFor.${system}.native;
|
||||||
in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
|
in pkgs.buildPackages.runCommand "test-rl-next-release-notes" { } ''
|
||||||
LANG=C.UTF-8 ${(commonDeps { inherit pkgs; }).changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out
|
LANG=C.UTF-8 ${pkgs.changelog-d}/bin/changelog-d ${./doc/manual/rl-next} >$out
|
||||||
'';
|
'';
|
||||||
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
|
} // (lib.optionalAttrs (builtins.elem system linux64BitSystems)) {
|
||||||
dockerImage = self.hydraJobs.dockerImage.${system};
|
dockerImage = self.hydraJobs.dockerImage.${system};
|
||||||
|
@ -629,36 +405,25 @@
|
||||||
devShells = let
|
devShells = let
|
||||||
makeShell = pkgs: stdenv:
|
makeShell = pkgs: stdenv:
|
||||||
let
|
let
|
||||||
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
nix = pkgs.callPackage ./package.nix {
|
||||||
|
inherit stdenv versionSuffix fileset;
|
||||||
|
boehmgc = pkgs.boehmgc-nix;
|
||||||
|
busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
with commonDeps { inherit pkgs; };
|
nix.overrideAttrs (prev: {
|
||||||
stdenv.mkDerivation {
|
nativeBuildInputs = prev.nativeBuildInputs
|
||||||
name = "nix";
|
|
||||||
|
|
||||||
outputs = [ "out" "dev" "doc" ];
|
|
||||||
|
|
||||||
nativeBuildInputs = nativeBuildDeps
|
|
||||||
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
|
++ lib.optional (stdenv.cc.isClang && !stdenv.buildPlatform.isDarwin) pkgs.buildPackages.bear
|
||||||
++ lib.optional
|
++ lib.optional
|
||||||
(stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform)
|
(stdenv.cc.isClang && stdenv.hostPlatform == stdenv.buildPlatform)
|
||||||
pkgs.buildPackages.clang-tools
|
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
|
src = null;
|
||||||
++ awsDeps ++ checkDeps ++ internalApiDocsDeps;
|
|
||||||
|
|
||||||
configureFlags = configureFlags
|
|
||||||
++ testConfigureFlags ++ internalApiDocsConfigureFlags
|
|
||||||
++ lib.optional (!canRunInstalled) "--disable-doc-gen";
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
|
|
||||||
installFlags = "sysconfdir=$(out)/etc";
|
installFlags = "sysconfdir=$(out)/etc";
|
||||||
|
strictDeps = false;
|
||||||
|
|
||||||
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
|
||||||
|
@ -666,7 +431,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
|
||||||
|
|
261
package.nix
Normal file
261
package.nix
Normal file
|
@ -0,0 +1,261 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
autoconf-archive,
|
||||||
|
autoreconfHook,
|
||||||
|
aws-sdk-cpp,
|
||||||
|
boehmgc,
|
||||||
|
nlohmann_json,
|
||||||
|
bison,
|
||||||
|
changelog-d,
|
||||||
|
boost,
|
||||||
|
brotli,
|
||||||
|
bzip2,
|
||||||
|
curl,
|
||||||
|
doxygen,
|
||||||
|
editline,
|
||||||
|
fileset,
|
||||||
|
flex,
|
||||||
|
git,
|
||||||
|
gtest,
|
||||||
|
jq,
|
||||||
|
libarchive,
|
||||||
|
libcpuid,
|
||||||
|
libseccomp,
|
||||||
|
libsodium,
|
||||||
|
lowdown,
|
||||||
|
mdbook,
|
||||||
|
mdbook-linkcheck,
|
||||||
|
mercurial,
|
||||||
|
openssl,
|
||||||
|
pkg-config,
|
||||||
|
rapidcheck,
|
||||||
|
sqlite,
|
||||||
|
util-linuxMinimal ? utillinuxMinimal,
|
||||||
|
utillinuxMinimal ? null,
|
||||||
|
xz,
|
||||||
|
|
||||||
|
busybox-sandbox-shell,
|
||||||
|
|
||||||
|
pname ? "nix",
|
||||||
|
versionSuffix ? "",
|
||||||
|
officialRelease ? true,
|
||||||
|
# Set to true to build the release notes for the next release.
|
||||||
|
buildUnreleasedNotes ? false,
|
||||||
|
internalApiDocs ? false,
|
||||||
|
|
||||||
|
# Not a real argument, just the only way to approximate let-binding some
|
||||||
|
# stuff for argument defaults.
|
||||||
|
__forDefaults ? {
|
||||||
|
canRunInstalled = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||||
|
},
|
||||||
|
}: let
|
||||||
|
inherit (__forDefaults) canRunInstalled;
|
||||||
|
|
||||||
|
version = lib.fileContents ./.version + versionSuffix;
|
||||||
|
|
||||||
|
aws-sdk-cpp-nix = aws-sdk-cpp.override {
|
||||||
|
apis = [ "s3" "transfer" ];
|
||||||
|
customMemoryManagement = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
testConfigureFlags = [
|
||||||
|
"RAPIDCHECK_HEADERS=${lib.getDev rapidcheck}/extras/gtest/include"
|
||||||
|
];
|
||||||
|
|
||||||
|
# The internal API docs need these for the build, but if we're not building
|
||||||
|
# Nix itself, then these don't need to be propagated.
|
||||||
|
maybePropagatedInputs = [
|
||||||
|
boehmgc
|
||||||
|
nlohmann_json
|
||||||
|
];
|
||||||
|
|
||||||
|
# .gitignore has already been processed, so any changes in it are irrelevant
|
||||||
|
# at this point. It is not represented verbatim for test purposes because
|
||||||
|
# that would interfere with repo semantics.
|
||||||
|
baseFiles = fileset.fileFilter (f: f.name != ".gitignore") ./.;
|
||||||
|
|
||||||
|
configureFiles = fileset.unions [
|
||||||
|
./.version
|
||||||
|
./configure.ac
|
||||||
|
./m4
|
||||||
|
# TODO: do we really need README.md? It doesn't seem used in the build.
|
||||||
|
./README.md
|
||||||
|
];
|
||||||
|
|
||||||
|
topLevelBuildFiles = fileset.unions [
|
||||||
|
./local.mk
|
||||||
|
./Makefile
|
||||||
|
./Makefile.config.in
|
||||||
|
./mk
|
||||||
|
];
|
||||||
|
|
||||||
|
functionalTestFiles = fileset.unions [
|
||||||
|
./tests/functional
|
||||||
|
./tests/unit
|
||||||
|
(fileset.fileFilter (f: lib.strings.hasPrefix "nix-profile" f.name) ./scripts)
|
||||||
|
];
|
||||||
|
|
||||||
|
in stdenv.mkDerivation (finalAttrs: {
|
||||||
|
inherit pname version;
|
||||||
|
|
||||||
|
src = fileset.toSource {
|
||||||
|
root = ./.;
|
||||||
|
fileset = fileset.intersection baseFiles (fileset.unions ([
|
||||||
|
configureFiles
|
||||||
|
topLevelBuildFiles
|
||||||
|
functionalTestFiles
|
||||||
|
./unit-test-data
|
||||||
|
] ++ lib.optionals (!finalAttrs.dontBuild || internalApiDocs) [
|
||||||
|
./boehmgc-coroutine-sp-fallback.diff
|
||||||
|
./doc
|
||||||
|
./misc
|
||||||
|
./precompiled-headers.h
|
||||||
|
./src
|
||||||
|
./COPYING
|
||||||
|
./scripts/local.mk
|
||||||
|
]));
|
||||||
|
};
|
||||||
|
|
||||||
|
VERSION_SUFFIX = versionSuffix;
|
||||||
|
|
||||||
|
outputs = [ "out" ]
|
||||||
|
++ lib.optionals (!finalAttrs.dontBuild) [ "dev" "doc" ];
|
||||||
|
|
||||||
|
dontBuild = false;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
bison
|
||||||
|
flex
|
||||||
|
] ++ [
|
||||||
|
(lib.getBin lowdown)
|
||||||
|
mdbook
|
||||||
|
mdbook-linkcheck
|
||||||
|
autoconf-archive
|
||||||
|
autoreconfHook
|
||||||
|
pkg-config
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
git
|
||||||
|
mercurial
|
||||||
|
jq
|
||||||
|
] ++ lib.optional stdenv.hostPlatform.isLinux util-linuxMinimal
|
||||||
|
++ lib.optional (!officialRelease && buildUnreleasedNotes) changelog-d
|
||||||
|
++ lib.optional internalApiDocs doxygen
|
||||||
|
;
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
curl
|
||||||
|
bzip2
|
||||||
|
xz
|
||||||
|
brotli
|
||||||
|
editline
|
||||||
|
openssl
|
||||||
|
sqlite
|
||||||
|
libarchive
|
||||||
|
boost
|
||||||
|
lowdown
|
||||||
|
libsodium
|
||||||
|
]
|
||||||
|
++ lib.optionals stdenv.isLinux [ libseccomp ]
|
||||||
|
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
|
||||||
|
# There have been issues building these dependencies
|
||||||
|
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) aws-sdk-cpp-nix
|
||||||
|
++ lib.optionals (finalAttrs.dontBuild) maybePropagatedInputs
|
||||||
|
;
|
||||||
|
|
||||||
|
checkInputs = [
|
||||||
|
gtest
|
||||||
|
rapidcheck
|
||||||
|
];
|
||||||
|
|
||||||
|
propagatedBuildInputs = lib.optionals (!finalAttrs.dontBuild) maybePropagatedInputs;
|
||||||
|
|
||||||
|
disallowedReferences = [
|
||||||
|
boost
|
||||||
|
];
|
||||||
|
|
||||||
|
preConfigure = lib.optionalString (!finalAttrs.dontBuild && !stdenv.hostPlatform.isStatic) ''
|
||||||
|
# Copy libboost_context so we don't get all of Boost in our closure.
|
||||||
|
# https://github.com/NixOS/nixpkgs/issues/45462
|
||||||
|
mkdir -p $out/lib
|
||||||
|
cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
|
||||||
|
rm -f $out/lib/*.a
|
||||||
|
'' + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isLinux) ''
|
||||||
|
chmod u+w $out/lib/*.so.*
|
||||||
|
patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
|
||||||
|
'' + lib.optionalString (!finalAttrs.dontBuild && stdenv.hostPlatform.isDarwin) ''
|
||||||
|
for LIB in $out/lib/*.dylib; do
|
||||||
|
chmod u+w $LIB
|
||||||
|
install_name_tool -id $LIB $LIB
|
||||||
|
install_name_tool -delete_rpath ${boost}/lib/ $LIB || true
|
||||||
|
done
|
||||||
|
install_name_tool -change ${boost}/lib/libboost_system.dylib $out/lib/libboost_system.dylib $out/lib/libboost_thread.dylib
|
||||||
|
'' + ''
|
||||||
|
# Workaround https://github.com/NixOS/nixpkgs/issues/294890.
|
||||||
|
if [[ -n "''${doCheck:-}" ]]; then
|
||||||
|
appendToVar configureFlags "--enable-tests"
|
||||||
|
else
|
||||||
|
appendToVar configureFlags "--disable-tests"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
configureFlags = lib.optionals stdenv.isLinux [
|
||||||
|
"--with-boost=${boost}/lib"
|
||||||
|
"--with-sandbox-shell=${busybox-sandbox-shell}/bin/busybox"
|
||||||
|
] ++ lib.optionals (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) [
|
||||||
|
"LDFLAGS=-fuse-ld=gold"
|
||||||
|
] ++ [ "--sysconfdir=/etc" ]
|
||||||
|
++ lib.optional stdenv.hostPlatform.isStatic "--enable-embedded-sandbox-shell"
|
||||||
|
++ lib.optionals (finalAttrs.doCheck || internalApiDocs) testConfigureFlags
|
||||||
|
++ lib.optional (!canRunInstalled) "--disable-doc-gen"
|
||||||
|
++ [ (lib.enableFeature internalApiDocs "internal-api-docs") ]
|
||||||
|
;
|
||||||
|
|
||||||
|
installTargets = lib.optional internalApiDocs "internal-api-html";
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
|
makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1";
|
||||||
|
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
installFlags = "sysconfdir=$(out)/etc";
|
||||||
|
|
||||||
|
postInstall = lib.optionalString (!finalAttrs.dontBuild) ''
|
||||||
|
mkdir -p $doc/nix-support
|
||||||
|
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
|
||||||
|
'' + lib.optionalString stdenv.hostPlatform.isStatic ''
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
echo "file binary-dist $out/bin/nix" >> $out/nix-support/hydra-build-products
|
||||||
|
'' + lib.optionalString stdenv.isDarwin ''
|
||||||
|
install_name_tool \
|
||||||
|
-change ${boost}/lib/libboost_context.dylib \
|
||||||
|
$out/lib/libboost_context.dylib \
|
||||||
|
$out/lib/libnixutil.dylib
|
||||||
|
'' + lib.optionalString internalApiDocs ''
|
||||||
|
mkdir -p $out/nix-support
|
||||||
|
echo "doc internal-api-docs $out/share/doc/nix/internal-api/html" >> "$out/nix-support/hydra-build-products"
|
||||||
|
'';
|
||||||
|
|
||||||
|
doInstallCheck = finalAttrs.doCheck;
|
||||||
|
installCheckFlags = "sysconfdir=$(out)/etc";
|
||||||
|
installCheckTarget = "installcheck"; # work around buggy detection in stdenv
|
||||||
|
|
||||||
|
preInstallCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||||
|
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
||||||
|
'';
|
||||||
|
|
||||||
|
separateDebugInfo = !stdenv.hostPlatform.isStatic && !finalAttrs.dontBuild;
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||||
|
|
||||||
|
meta.platforms = lib.platforms.unix;
|
||||||
|
|
||||||
|
passthru.perl-bindings = pkgs.callPackage ./perl {
|
||||||
|
inherit fileset stdenv;
|
||||||
|
};
|
||||||
|
})
|
Loading…
Reference in a new issue