2024-06-27 05:15:33 +03:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2024-07-01 21:36:46 +03:00
|
|
|
, mkMesonDerivation
|
2024-06-27 05:15:33 +03:00
|
|
|
, releaseTools
|
|
|
|
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, pkg-config
|
2024-06-28 02:19:32 +03:00
|
|
|
, bison
|
|
|
|
, flex
|
|
|
|
, cmake # for resolving toml11 dep
|
2024-06-27 05:15:33 +03:00
|
|
|
|
|
|
|
, nix-util
|
|
|
|
, nix-store
|
|
|
|
, nix-fetchers
|
|
|
|
, boost
|
|
|
|
, boehmgc
|
|
|
|
, nlohmann_json
|
2024-06-28 02:19:32 +03:00
|
|
|
, toml11
|
2024-06-27 05:15:33 +03:00
|
|
|
|
|
|
|
# Configuration Options
|
|
|
|
|
2024-07-06 18:36:31 +03:00
|
|
|
, version
|
2024-06-27 05:15:33 +03:00
|
|
|
|
|
|
|
# Whether to use garbage collection for the Nix language evaluator.
|
|
|
|
#
|
|
|
|
# If it is disabled, we just leak memory, but this is not as bad as it
|
|
|
|
# sounds so long as evaluation just takes places within short-lived
|
|
|
|
# processes. (When the process exits, the memory is reclaimed; it is
|
|
|
|
# only leaked *within* the process.)
|
|
|
|
#
|
|
|
|
# Temporarily disabled on Windows because the `GC_throw_bad_alloc`
|
|
|
|
# symbol is missing during linking.
|
|
|
|
, enableGC ? !stdenv.hostPlatform.isWindows
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) fileset;
|
|
|
|
in
|
|
|
|
|
2024-07-01 21:36:46 +03:00
|
|
|
mkMesonDerivation (finalAttrs: {
|
2024-06-27 05:15:33 +03:00
|
|
|
pname = "nix-expr";
|
|
|
|
inherit version;
|
|
|
|
|
2024-07-01 21:36:46 +03:00
|
|
|
workDir = ./.;
|
|
|
|
fileset = fileset.unions [
|
|
|
|
../../build-utils-meson
|
|
|
|
./build-utils-meson
|
|
|
|
../../.version
|
|
|
|
./.version
|
|
|
|
./meson.build
|
|
|
|
./meson.options
|
|
|
|
./primops/meson.build
|
|
|
|
(fileset.fileFilter (file: file.hasExt "cc") ./.)
|
|
|
|
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
|
|
|
./lexer.l
|
|
|
|
./parser.y
|
|
|
|
(fileset.fileFilter (file: file.hasExt "nix") ./.)
|
|
|
|
];
|
2024-06-27 05:15:33 +03:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
pkg-config
|
2024-06-28 02:19:32 +03:00
|
|
|
bison
|
|
|
|
flex
|
|
|
|
cmake
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
toml11
|
2024-06-27 05:15:33 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
nix-util
|
|
|
|
nix-store
|
|
|
|
nix-fetchers
|
2024-06-28 00:28:31 +03:00
|
|
|
boost
|
2024-06-27 05:15:33 +03:00
|
|
|
nlohmann_json
|
|
|
|
] ++ lib.optional enableGC boehmgc;
|
|
|
|
|
|
|
|
preConfigure =
|
2024-06-28 02:19:32 +03:00
|
|
|
# "Inline" .version so it's not a symlink, and includes the suffix.
|
|
|
|
# Do the meson utils, without modification.
|
2024-06-27 05:15:33 +03:00
|
|
|
''
|
2024-07-01 21:36:46 +03:00
|
|
|
chmod u+w ./.version
|
|
|
|
echo ${version} > ../../.version
|
2024-06-27 05:15:33 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
mesonFlags = [
|
2024-06-28 01:09:32 +03:00
|
|
|
(lib.mesonEnable "gc" enableGC)
|
2024-06-27 05:15:33 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
env = {
|
|
|
|
# Needed for Meson to find Boost.
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/86131.
|
|
|
|
BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
|
|
|
|
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
|
|
|
|
} // lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
|
|
|
|
LDFLAGS = "-fuse-ld=gold";
|
|
|
|
};
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
|
|
|
|
2024-07-01 21:36:46 +03:00
|
|
|
strictDeps = true;
|
2024-06-27 05:15:33 +03:00
|
|
|
|
|
|
|
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
|
|
|
};
|
|
|
|
|
|
|
|
})
|