mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Package the Nix CLI with Meson
Co-Authored-By: Qyriad <qyriad@qyriad.me>
This commit is contained in:
parent
f1d88e0f27
commit
7a6269ba7b
21 changed files with 326 additions and 18 deletions
|
@ -15,6 +15,9 @@ subproject('libflake')
|
|||
subproject('libmain')
|
||||
subproject('libcmd')
|
||||
|
||||
# Executables
|
||||
subproject('nix')
|
||||
|
||||
# Docs
|
||||
subproject('internal-api-docs')
|
||||
subproject('external-api-docs')
|
||||
|
|
|
@ -32,6 +32,9 @@ in
|
|||
|
||||
nix-cmd = callPackage ../src/libcmd/package.nix { };
|
||||
|
||||
# Will replace `nix` once the old build system is gone.
|
||||
nix-ng = callPackage ../src/nix/package.nix { };
|
||||
|
||||
nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { };
|
||||
nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { };
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ let
|
|||
"nix-flake-tests"
|
||||
"nix-main"
|
||||
"nix-cmd"
|
||||
"nix-ng"
|
||||
];
|
||||
in
|
||||
{
|
||||
|
|
1
src/nix/.version
Symbolic link
1
src/nix/.version
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../.version
|
1
src/nix/build-remote
Symbolic link
1
src/nix/build-remote
Symbolic link
|
@ -0,0 +1 @@
|
|||
../build-remote
|
1
src/nix/build-utils-meson
Symbolic link
1
src/nix/build-utils-meson
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../build-utils-meson/
|
1
src/nix/doc
Symbolic link
1
src/nix/doc
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../doc
|
1
src/nix/help-stores.md
Symbolic link
1
src/nix/help-stores.md
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../doc/manual/src/store/types/index.md.in
|
|
@ -42,27 +42,16 @@ $(eval $(call install-symlink, $(bindir)/nix, $(libexecdir)/nix/build-remote))
|
|||
|
||||
src/nix-env/user-env.cc: src/nix-env/buildenv.nix.gen.hh
|
||||
|
||||
src/nix/develop.cc: src/nix/get-env.sh.gen.hh
|
||||
$(d)/develop.cc: $(d)/get-env.sh.gen.hh
|
||||
|
||||
src/nix-channel/nix-channel.cc: src/nix-channel/unpack-channel.nix.gen.hh
|
||||
|
||||
src/nix/main.cc: \
|
||||
$(d)/main.cc: \
|
||||
doc/manual/generate-manpage.nix.gen.hh \
|
||||
doc/manual/utils.nix.gen.hh doc/manual/generate-settings.nix.gen.hh \
|
||||
doc/manual/generate-store-info.nix.gen.hh \
|
||||
src/nix/generated-doc/help-stores.md
|
||||
$(d)/help-stores.md.gen.hh
|
||||
|
||||
src/nix/generated-doc/files/%.md: doc/manual/src/command-ref/files/%.md
|
||||
@mkdir -p $$(dirname $@)
|
||||
@cp $< $@
|
||||
$(d)/profile.cc: $(d)/profile.md
|
||||
|
||||
src/nix/profile.cc: src/nix/profile.md src/nix/generated-doc/files/profiles.md.gen.hh
|
||||
|
||||
src/nix/generated-doc/help-stores.md: doc/manual/src/store/types/index.md.in
|
||||
@mkdir -p $$(dirname $@)
|
||||
@echo 'R"(' >> $@.tmp
|
||||
@echo >> $@.tmp
|
||||
@cat $^ >> $@.tmp
|
||||
@echo >> $@.tmp
|
||||
@echo ')"' >> $@.tmp
|
||||
@mv $@.tmp $@
|
||||
$(d)/profile.md: $(d)/profiles.md.gen.hh
|
||||
|
|
|
@ -333,7 +333,7 @@ struct CmdHelpStores : Command
|
|||
std::string doc() override
|
||||
{
|
||||
return
|
||||
#include "generated-doc/help-stores.md"
|
||||
#include "help-stores.md.gen.hh"
|
||||
;
|
||||
}
|
||||
|
||||
|
|
170
src/nix/meson.build
Normal file
170
src/nix/meson.build
Normal file
|
@ -0,0 +1,170 @@
|
|||
project('nix', 'cpp',
|
||||
version : files('.version'),
|
||||
default_options : [
|
||||
'cpp_std=c++2a',
|
||||
# TODO(Qyriad): increase the warning level
|
||||
'warning_level=1',
|
||||
'debug=true',
|
||||
'optimization=2',
|
||||
'errorlogs=true', # Please print logs for tests that fail
|
||||
],
|
||||
meson_version : '>= 1.1',
|
||||
license : 'LGPL-2.1-or-later',
|
||||
)
|
||||
|
||||
cxx = meson.get_compiler('cpp')
|
||||
|
||||
subdir('build-utils-meson/deps-lists')
|
||||
|
||||
deps_private_maybe_subproject = [
|
||||
dependency('nix-util'),
|
||||
dependency('nix-store'),
|
||||
dependency('nix-expr'),
|
||||
dependency('nix-fetchers'),
|
||||
dependency('nix-main'),
|
||||
dependency('nix-cmd'),
|
||||
]
|
||||
deps_public_maybe_subproject = [
|
||||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/export-all-symbols')
|
||||
|
||||
add_project_arguments(
|
||||
# TODO(Qyriad): Yes this is how the autoconf+Make system did it.
|
||||
# It would be nice for our headers to be idempotent instead.
|
||||
'-include', 'config-util.hh',
|
||||
'-include', 'config-store.hh',
|
||||
'-include', 'config-expr.hh',
|
||||
#'-include', 'config-fetchers.hh',
|
||||
'-include', 'config-main.hh',
|
||||
'-include', 'config-cmd.hh',
|
||||
language : 'cpp',
|
||||
)
|
||||
|
||||
subdir('build-utils-meson/diagnostics')
|
||||
subdir('build-utils-meson/generate-header')
|
||||
|
||||
nix_sources = files(
|
||||
'add-to-store.cc',
|
||||
'app.cc',
|
||||
'build.cc',
|
||||
'bundle.cc',
|
||||
'cat.cc',
|
||||
'config-check.cc',
|
||||
'config.cc',
|
||||
'copy.cc',
|
||||
'derivation-add.cc',
|
||||
'derivation-show.cc',
|
||||
'derivation.cc',
|
||||
'develop.cc',
|
||||
'diff-closures.cc',
|
||||
'dump-path.cc',
|
||||
'edit.cc',
|
||||
'env.cc',
|
||||
'eval.cc',
|
||||
'flake.cc',
|
||||
'fmt.cc',
|
||||
'hash.cc',
|
||||
'log.cc',
|
||||
'ls.cc',
|
||||
'main.cc',
|
||||
'make-content-addressed.cc',
|
||||
'nar.cc',
|
||||
'optimise-store.cc',
|
||||
'path-from-hash-part.cc',
|
||||
'path-info.cc',
|
||||
'prefetch.cc',
|
||||
'profile.cc',
|
||||
'realisation.cc',
|
||||
'registry.cc',
|
||||
'repl.cc',
|
||||
'run.cc',
|
||||
'search.cc',
|
||||
'sigs.cc',
|
||||
'store-copy-log.cc',
|
||||
'store-delete.cc',
|
||||
'store-gc.cc',
|
||||
'store-info.cc',
|
||||
'store-repair.cc',
|
||||
'store.cc',
|
||||
'unix/daemon.cc',
|
||||
'upgrade-nix.cc',
|
||||
'verify.cc',
|
||||
'why-depends.cc',
|
||||
)
|
||||
|
||||
nix_sources += [
|
||||
gen_header.process('doc/manual/generate-manpage.nix'),
|
||||
gen_header.process('doc/manual/generate-settings.nix'),
|
||||
gen_header.process('doc/manual/generate-store-info.nix'),
|
||||
gen_header.process('doc/manual/utils.nix'),
|
||||
gen_header.process('get-env.sh'),
|
||||
gen_header.process('profiles.md'),
|
||||
gen_header.process('help-stores.md'),
|
||||
]
|
||||
|
||||
if host_machine.system() != 'windows'
|
||||
nix_sources += files(
|
||||
'unix/daemon.cc',
|
||||
)
|
||||
endif
|
||||
|
||||
# The rest of the subdirectories aren't separate components,
|
||||
# just source files in another directory, so we process them here.
|
||||
|
||||
build_remote_sources = files(
|
||||
'build-remote/build-remote.cc',
|
||||
)
|
||||
nix_build_sources = files(
|
||||
'nix-build/nix-build.cc',
|
||||
)
|
||||
nix_channel_sources = files(
|
||||
'nix-channel/nix-channel.cc',
|
||||
)
|
||||
unpack_channel_gen = gen_header.process('nix-channel/unpack-channel.nix')
|
||||
nix_collect_garbage_sources = files(
|
||||
'nix-collect-garbage/nix-collect-garbage.cc',
|
||||
)
|
||||
nix_copy_closure_sources = files(
|
||||
'nix-copy-closure/nix-copy-closure.cc',
|
||||
)
|
||||
nix_env_buildenv_gen = gen_header.process('nix-env/buildenv.nix')
|
||||
nix_env_sources = files(
|
||||
'nix-env/nix-env.cc',
|
||||
'nix-env/user-env.cc',
|
||||
)
|
||||
nix_instantiate_sources = files(
|
||||
'nix-instantiate/nix-instantiate.cc',
|
||||
)
|
||||
nix_store_sources = files(
|
||||
'nix-store/dotgraph.cc',
|
||||
'nix-store/graphml.cc',
|
||||
'nix-store/nix-store.cc',
|
||||
)
|
||||
|
||||
# Hurray for Meson list flattening!
|
||||
sources = [
|
||||
nix_sources,
|
||||
build_remote_sources,
|
||||
nix_build_sources,
|
||||
nix_channel_sources,
|
||||
unpack_channel_gen,
|
||||
nix_collect_garbage_sources,
|
||||
nix_copy_closure_sources,
|
||||
nix_env_buildenv_gen,
|
||||
nix_env_sources,
|
||||
nix_instantiate_sources,
|
||||
nix_store_sources,
|
||||
]
|
||||
|
||||
include_dirs = [include_directories('.')]
|
||||
|
||||
this_exe = executable(
|
||||
meson.project_name(),
|
||||
sources,
|
||||
dependencies : deps_private_subproject + deps_private + deps_other,
|
||||
include_directories : include_dirs,
|
||||
link_args: linker_export_flags,
|
||||
install : true,
|
||||
)
|
1
src/nix/nix-build
Symbolic link
1
src/nix/nix-build
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-build
|
1
src/nix/nix-channel
Symbolic link
1
src/nix/nix-channel
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-channel
|
1
src/nix/nix-collect-garbage
Symbolic link
1
src/nix/nix-collect-garbage
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-collect-garbage
|
1
src/nix/nix-copy-closure
Symbolic link
1
src/nix/nix-copy-closure
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-copy-closure
|
1
src/nix/nix-env
Symbolic link
1
src/nix/nix-env
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-env
|
1
src/nix/nix-instantiate
Symbolic link
1
src/nix/nix-instantiate
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-instantiate
|
1
src/nix/nix-store
Symbolic link
1
src/nix/nix-store
Symbolic link
|
@ -0,0 +1 @@
|
|||
../nix-store/
|
129
src/nix/package.nix
Normal file
129
src/nix/package.nix
Normal file
|
@ -0,0 +1,129 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, mkMesonDerivation
|
||||
, releaseTools
|
||||
|
||||
, meson
|
||||
, ninja
|
||||
, pkg-config
|
||||
|
||||
, nix-store
|
||||
, nix-expr
|
||||
, nix-main
|
||||
, nix-cmd
|
||||
|
||||
, rapidcheck
|
||||
, gtest
|
||||
, runCommand
|
||||
|
||||
# Configuration Options
|
||||
|
||||
, version
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) fileset;
|
||||
in
|
||||
|
||||
mkMesonDerivation (finalAttrs: {
|
||||
pname = "nix";
|
||||
inherit version;
|
||||
|
||||
workDir = ./.;
|
||||
fileset = fileset.unions ([
|
||||
../../build-utils-meson
|
||||
./build-utils-meson
|
||||
../../.version
|
||||
./.version
|
||||
./meson.build
|
||||
# ./meson.options
|
||||
|
||||
# Symbolic links to other dirs
|
||||
./build-remote
|
||||
./doc
|
||||
./nix-build
|
||||
./nix-channel
|
||||
./nix-collect-garbage
|
||||
./nix-copy-closure
|
||||
./nix-env
|
||||
./nix-instantiate
|
||||
./nix-store
|
||||
|
||||
# Doc nix files for --help
|
||||
../../doc/manual/generate-manpage.nix
|
||||
../../doc/manual/utils.nix
|
||||
../../doc/manual/generate-settings.nix
|
||||
../../doc/manual/generate-store-info.nix
|
||||
|
||||
# Other files to be included as string literals
|
||||
../nix-channel/unpack-channel.nix
|
||||
../nix-env/buildenv.nix
|
||||
./get-env.sh
|
||||
./help-stores.md
|
||||
../../doc/manual/src/store/types/index.md.in
|
||||
./profiles.md
|
||||
../../doc/manual/src/command-ref/files/profiles.md
|
||||
|
||||
# Files
|
||||
] ++ lib.concatMap
|
||||
(dir: [
|
||||
(fileset.fileFilter (file: file.hasExt "cc") dir)
|
||||
(fileset.fileFilter (file: file.hasExt "hh") dir)
|
||||
(fileset.fileFilter (file: file.hasExt "md") dir)
|
||||
])
|
||||
[
|
||||
./.
|
||||
../build-remote
|
||||
../nix-build
|
||||
../nix-channel
|
||||
../nix-collect-garbage
|
||||
../nix-copy-closure
|
||||
../nix-env
|
||||
../nix-instantiate
|
||||
../nix-store
|
||||
]
|
||||
);
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
nix-store
|
||||
nix-expr
|
||||
nix-main
|
||||
nix-cmd
|
||||
];
|
||||
|
||||
preConfigure =
|
||||
# "Inline" .version so it's not a symlink, and includes the suffix.
|
||||
# Do the meson utils, without modification.
|
||||
''
|
||||
chmod u+w ./.version
|
||||
echo ${version} > ../../../.version
|
||||
'';
|
||||
|
||||
mesonFlags = [
|
||||
];
|
||||
|
||||
env = lib.optionalAttrs (stdenv.isLinux && !(stdenv.hostPlatform.isStatic && stdenv.system == "aarch64-linux")) {
|
||||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
};
|
||||
|
||||
})
|
|
@ -11,7 +11,7 @@ them to be rolled back easily.
|
|||
|
||||
)""
|
||||
|
||||
#include "generated-doc/files/profiles.md.gen.hh"
|
||||
#include "profiles.md.gen.hh"
|
||||
|
||||
R""(
|
||||
|
||||
|
|
1
src/nix/profiles.md
Symbolic link
1
src/nix/profiles.md
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../doc/manual/src/command-ref/files/profiles.md
|
Loading…
Reference in a new issue