Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix 2.25 #339

Merged
merged 17 commits into from
Nov 25, 2024
Merged
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 .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Checks:
# don't find them too problematic
- -readability-identifier-length
- -readability-magic-numbers
- -bugprone-easily-swappable-parameters

# maybe address this in the future
- -readability-function-cognitive-complexity
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/nix-github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
install_url: https://releases.nixos.org/nix/nix-2.25.2/install
- id: set-matrix
name: Generate Nix Matrix
run: |
Expand All @@ -24,13 +26,16 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
fail-fast: false
steps:
- name: Figure out if we are running in a Namespace.so runner or not
shell: bash
run: |
if [ -n "$NSC_CONTAINER_REGISTRY" ]; then
echo "NAMESPACE_RUNNER=1" >> $GITHUB_ENV
fi
- uses: DeterminateSystems/magic-nix-cache-action@main
if: ${{ ! env.NAMESPACE_RUNNER }}
- name: namespacelabs/nscloud-cache-action cannot mkdir /nix so we do it manually
if: env.NAMESPACE_RUNNER
shell: bash
Expand Down Expand Up @@ -59,6 +64,7 @@ jobs:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build
run: nix develop -c bash -c 'meson setup -Db_sanitize=address,undefined build && ninja -C build'
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion .nix-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2_24
2_25
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"nscloud-cache-tag-nix-eval-jobs"
];
"x86_64-darwin" = "macos-13";
"aarch64-darwin" = "macos-14";
"aarch64-darwin" = "macos-latest";
"aarch64-linux" = [
"nscloud-ubuntu-22.04-arm64-4x16-with-cache"
"nscloud-cache-size-20gb"
Expand Down
14 changes: 9 additions & 5 deletions src/drv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
#include <nix/error.hh>
#include <nix/eval-error.hh>
#include <nix/experimental-features.hh>
// required for std::optional
#include <nix/json-utils.hh> //NOLINT(misc-include-cleaner)
#include <nix/pos-idx.hh>
#include <cstdint>
#include <string>
#include <exception>
#include <sstream>
#include <vector>
#include <optional>
#include <map>
#include <optional>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "drv.hh"
#include "eval-args.hh"
Expand Down Expand Up @@ -63,13 +66,14 @@ auto queryCacheStatus(nix::Store &store,
}
return Drv::CacheStatus::NotBuilt;
};

} // namespace

/* The fields of a derivation that are printed in json form */
Drv::Drv(std::string &attrPath, nix::EvalState &state,
nix::PackageInfo &packageInfo, MyArgs &args,
std::optional<Constituents> constituents)
: constituents(constituents) {
: constituents(std::move(constituents)) {

auto localStore = state.store.dynamic_pointer_cast<nix::LocalFSStore>();

Expand Down
11 changes: 8 additions & 3 deletions src/drv.hh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#include <nix/get-drvs.hh>
#include <nix/eval.hh>
#include <nlohmann/json_fwd.hpp>
// we need this include or otherwise we cannot instantiate std::optional
#include <nlohmann/json.hpp> //NOLINT(misc-include-cleaner)
Comment on lines +4 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do this in drv.hh or drv.cc? I would think just the latter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I drop it, clang-tidy gets really unhappy:

error: implicit instantiation of undefined template 'nlohmann::basic_json<>' [clang-diagnostic-error]

This is using

ninja clang-tidy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, for Drv::meta, and implicit constructors

#include <cstdint>
#include <string>
#include <map>
#include <set>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "eval-args.hh"

Expand All @@ -19,7 +23,8 @@ struct Constituents {
std::vector<std::string> namedConstituents;
Constituents(std::vector<std::string> constituents,
std::vector<std::string> namedConstituents)
: constituents(constituents), namedConstituents(namedConstituents) {};
: constituents(std::move(constituents)),
namedConstituents(std::move(namedConstituents)) {};
};

/* The fields of a derivation that are printed in json form */
Expand Down
8 changes: 5 additions & 3 deletions src/eval-args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#include <nix/common-eval-args.hh>
#include <nix/source-accessor.hh>
#include <nix/flake/flakeref.hh>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <iomanip>

#include "eval-args.hh"

Expand Down Expand Up @@ -109,7 +110,8 @@ MyArgs::MyArgs() : MixCommonArgs("nix-eval-jobs") {
lockFlags.inputOverrides.insert_or_assign(
nix::flake::parseInputPath(inputPath),
nix::parseFlakeRef(nix::fetchSettings, flakeRef,
nix::absPath("."), true));
nix::absPath(std::filesystem::path(".")),
true));
}},
});

Expand Down
88 changes: 46 additions & 42 deletions src/nix-eval-jobs.cc
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
#include <nix/config.h> // IWYU pragma: keep
#include <curl/curl.h>
#include <nix/derivations.hh>
#include <nix/local-fs-store.hh>
#include <nix/eval-settings.hh>
#include <nix/shared.hh>
#include <nix/sync.hh>
#include <nix/eval.hh>
#include <nix/eval-gc.hh>
#include <nix/terminal.hh>
#include <sys/wait.h>
#include <nlohmann/json.hpp>
#include <cerrno>
#include <pthread.h>
#include <csignal>
#include <cstdlib>
// NOLINTBEGIN(modernize-deprecated-headers)
// misc-include-cleaner wants these header rather than the C++ versions
#include <signal.h>
#include <stdlib.h>
#include <string.h>
// NOLINTEND(modernize-deprecated-headers)
#include <cassert>
#include <cerrno>
#include <condition_variable>
#include <csignal>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <nix/attr-set.hh>
#include <curl/curl.h>
#include <exception>
#include <filesystem>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <nix/common-eval-args.hh>
#include <nix/config.hh>
#include <nix/derivations.hh>
#include <nix/error.hh>
#include <nix/eval-gc.hh>
#include <nix/eval-settings.hh>
#include <nix/eval.hh>
#include <nix/file-descriptor.hh>
#include <nix/file-system.hh>
#include <nix/flake/flake.hh>
#include <nix/fmt.hh>
#include <nix/globals.hh>
#include <nix/local-fs-store.hh>
#include <nix/logging.hh>
#include <nlohmann/detail/iterators/iter_impl.hpp>
#include <nlohmann/json_fwd.hpp>
#include <nix/path.hh>
#include <nix/processes.hh>
#include <nix/ref.hh>
#include <nix/store-api.hh>
#include <sys/types.h>
#include <nix/common-eval-args.hh>
#include <nix/flake/flake.hh>
#include <nix/shared.hh>
#include <nix/signals.hh>
#include <nix/signals-impl.hh>
#include <nix/fmt.hh>
#include <condition_variable>
#include <filesystem>
#include <exception>
#include <functional>
#include <iostream>
#include <memory>
#include <nix/store-api.hh>
#include <nix/strings.hh>
#include <nix/sync.hh>
#include <nix/terminal.hh>
#include <nlohmann/detail/iterators/iter_impl.hpp>
#include <nlohmann/json.hpp>
#include <nlohmann/json_fwd.hpp>
#include <optional>
#include <pthread.h>
#include <set>
#include <span>
#include <string>
#include <string_view>
#include <sys/wait.h>
#include <unistd.h>
#include <utility>
#include <vector>
#include <span>

#include "eval-args.hh"
#include "buffered-io.hh"
Expand Down Expand Up @@ -465,14 +466,14 @@ auto main(int argc, char **argv) -> int {
if (namedConstituents != job_json.end() &&
!namedConstituents->empty()) {
bool broken = false;
auto drvPathAggregate =
store->parseStorePath((std::string)job_json["drvPath"]);
auto drvPathAggregate = store->parseStorePath(
static_cast<std::string>(job_json["drvPath"]));
auto drvAggregate = store->readDerivation(drvPathAggregate);
if (!job_json.contains("constituents")) {
job_json["constituents"] = nlohmann::json::array();
}
std::vector<std::string> errors;
for (auto child : *namedConstituents) {
for (const auto &child : *namedConstituents) {
auto childJob = state->jobs.find(child);
if (childJob == state->jobs.end()) {
broken = true;
Expand All @@ -484,8 +485,9 @@ auto main(int argc, char **argv) -> int {
errors.push_back(nix::fmt(
"%s: %s", child, childJob->second["error"]));
} else {
auto drvPathChild = store->parseStorePath(
(std::string)childJob->second["drvPath"]);
auto drvPathChild =
store->parseStorePath(static_cast<std::string>(
childJob->second["drvPath"]));
auto drvChild = store->readDerivation(drvPathChild);
job_json["constituents"].push_back(
store->printStorePath(drvPathChild));
Expand All @@ -508,12 +510,14 @@ auto main(int argc, char **argv) -> int {

auto hashModulo = nix::hashDerivationModulo(
*store, drvAggregate, true);
if (hashModulo.kind != nix::DrvHash::Kind::Regular)
if (hashModulo.kind != nix::DrvHash::Kind::Regular) {
continue;
}

auto h = hashModulo.hashes.find("out");
if (h == hashModulo.hashes.end())
if (h == hashModulo.hashes.end()) {
continue;
}
auto outPath =
store->makeOutputPath("out", h->second, drvName);
drvAggregate.env["out"] =
Expand All @@ -524,8 +528,8 @@ auto main(int argc, char **argv) -> int {
auto newDrvPath = store->printStorePath(
nix::writeDerivation(*store, drvAggregate));

if (myArgs.gcRootsDir != "") {
nix::Path root =
if (myArgs.gcRootsDir.empty()) {
const nix::Path root =
myArgs.gcRootsDir + "/" +
std::string(nix::baseNameOf(newDrvPath));
if (!nix::pathExists(root)) {
Expand Down
2 changes: 2 additions & 0 deletions src/strings-portable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#endif

#if defined(__GLIBC__)
#include <string.h> //NOLINT(modernize-deprecated-headers)

// Linux with glibc specific: sigabbrev_np
auto get_signal_name(int sig) -> const char * {
const char *name = sigabbrev_np(sig);
Expand Down
Loading
Loading