Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ project(

# Internal Libraries
subproject('libutil')
subproject('libroots')
subproject('libstore')
subproject('libfetchers')
subproject('libexpr')
Expand Down
2 changes: 2 additions & 0 deletions packaging/components.nix
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ in
nix-flake-c = callPackage ../src/libflake-c/package.nix { };
nix-flake-tests = callPackage ../src/libflake-tests/package.nix { };

nix-roots = callPackage ../src/libroots/package.nix { };

nix-main = callPackage ../src/libmain/package.nix { };
nix-main-c = callPackage ../src/libmain-c/package.nix { };

Expand Down
1 change: 1 addition & 0 deletions packaging/hydra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ let
"nix-flake-tests"
"nix-main"
"nix-main-c"
"nix-roots"
"nix-cmd"
"nix-cli"
"nix-functional-tests"
Expand Down
1 change: 1 addition & 0 deletions src/libroots/.version
5 changes: 5 additions & 0 deletions src/libroots/include/nix/roots/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Public headers directory

include_dirs = [ include_directories('../..') ]

headers = files('roots.hh')
31 changes: 31 additions & 0 deletions src/libroots/include/nix/roots/roots.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include "nix/util/strings.hh"
#include <boost/unordered/unordered_flat_map.hpp>
#include <boost/unordered/unordered_flat_set.hpp>
#include <filesystem>

namespace nix::roots_tracer {

struct TracerConfig
{
const std::filesystem::path storeDir = "/nix/store";
const std::filesystem::path stateDir = "/nix/var/nix";
const std::filesystem::path socketPath = "/nix/var/nix/gc-socket/socket";
};

/**
* A value of type `Roots` is a mapping from a store path to the set of roots that keep it alive
*/
typedef boost::unordered_flat_map<
std::string,
boost::unordered_flat_set<std::string, StringViewHash, std::equal_to<>>,
StringViewHash,
std::equal_to<>>
UncheckedRoots;

void findRuntimeRoots(const TracerConfig & opts, UncheckedRoots & unchecked, bool censor);

void findRoots(const TracerConfig & opts, const Path & path, std::filesystem::file_type type, UncheckedRoots & roots);

} // namespace nix::roots_tracer
73 changes: 73 additions & 0 deletions src/libroots/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
project(
'nix-roots',
'cpp',
version : files('.version'),
default_options : [
'cpp_std=c++23',
# TODO(Qyriad): increase the warning level
'warning_level=1',
'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('nix-meson-build-support/deps-lists')

deps_private_maybe_subproject = []
deps_public_maybe_subproject = [ dependency('nix-util') ]
subdir('nix-meson-build-support/subprojects')

subdir('nix-meson-build-support/common')

boost = dependency(
'boost',
modules : [
'container',
],
include_type : 'system',
)
deps_other += boost

configdata_priv = configuration_data()

lsof = find_program('lsof', required : false)
configdata_priv.set_quoted(
'LSOF',
lsof.found() ? lsof.full_path()
# Just look up on the PATH
: 'lsof',
)

config_priv_h = configure_file(
configuration : configdata_priv,
output : 'roots-config-private.hh',
)

sources = files(
'roots.cc',
)

subdir('include/nix/roots')

subdir('nix-meson-build-support/export-all-symbols')
subdir('nix-meson-build-support/windows-version')

this_library = library(
'nixroots',
sources,
config_priv_h,
soversion : nix_soversion,
dependencies : deps_public + deps_private + deps_other,
include_directories : include_dirs,
link_args : linker_export_flags,
install : true,
)

install_headers(headers, subdir : 'nix/roots', preserve_path : true)

libraries_private = []

subdir('nix-meson-build-support/export')
1 change: 1 addition & 0 deletions src/libroots/nix-meson-build-support
40 changes: 40 additions & 0 deletions src/libroots/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
lib,
mkMesonLibrary,

nix-util,

# Configuration Options

version,
}:

let
inherit (lib) fileset;
in

mkMesonLibrary (finalAttrs: {
pname = "nix-roots";
inherit version;

workDir = ./.;
fileset = fileset.unions [
../../nix-meson-build-support
./nix-meson-build-support
../../.version
./.version
./meson.build
./include/nix/roots/meson.build
(fileset.fileFilter (file: file.hasExt "cc") ./.)
(fileset.fileFilter (file: file.hasExt "hh") ./.)
];

propagatedBuildInputs = [
nix-util
];

meta = {
platforms = lib.platforms.unix ++ lib.platforms.windows;
};

})
Loading
Loading