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

[wip] fix compilation with nix 2.24 #613

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 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 @@ -33,7 +33,7 @@
callPackage
stdenv
;
nix = nixVersions.nix_2_19;
nix = nixVersions.nix_2_24;
llvmPackages = llvmPackages_16;
nixf = callPackage ./libnixf { };
nixt = callPackage ./libnixt { inherit nix; };
Expand Down
23 changes: 13 additions & 10 deletions libnixt/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{ lib
, stdenv
, meson
, ninja
, pkg-config
, nix
, gtest
, boost182
{
lib,
stdenv,
meson,
ninja,
pkg-config,
nix,
gtest,
boost182,
}:

stdenv.mkDerivation {
Expand All @@ -14,7 +15,10 @@ stdenv.mkDerivation {

src = ../.;

outputs = [ "out" "dev" ];
outputs = [
"out"
"dev"
];

mesonBuildType = "release";

Expand All @@ -36,7 +40,6 @@ stdenv.mkDerivation {

env.CXXFLAGS = "-include ${nix.dev}/include/nix/config.h";


meta = {
mainProgram = "nixt";
description = "Nix language frontend, parser & semantic analysis";
Expand Down
6 changes: 6 additions & 0 deletions libnixt/include/nixt/InitEval.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#pragma once

#include <nix/common-eval-args.hh>
#include <nix/eval-gc.hh>
#include <nix/eval-settings.hh>
#include <nix/eval.hh>
#include <nix/flake/flake.hh>
#include <nix/plugin.hh>
#include <nix/shared.hh>
#include <nix/store-api.hh>

Expand All @@ -9,6 +14,7 @@ namespace nixt {
inline void initEval() {
nix::initNix();
nix::initLibStore();
nix::flake::initLib(nix::flakeSettings);
nix::initPlugins();
nix::initGC();
}
Expand Down
6 changes: 3 additions & 3 deletions libnixt/lib/Flake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ void nixt::callDirtyFlake(EvalState &State, std::string_view Src,
nix::Value &VRes) {

nix::Value *VSrc = State.allocValue();
VSrc->mkPath(State.rootPath(nix::CanonPath(Src, nix::CanonPath::fromCwd())));
VSrc->mkPath(State.rootPath(nix::CanonPath(Src)));

auto *VFlakeCompat = State.allocValue();

nix::Expr *EFlakeCompat = State.parseExprFromString(
FlakeCompat, State.rootPath(nix::CanonPath::fromCwd()));
nix::Expr *EFlakeCompat =
State.parseExprFromString(FlakeCompat, State.rootPath("."));
State.eval(EFlakeCompat, *VFlakeCompat);

State.callFunction(*VFlakeCompat, *VSrc, VRes, noPos);
Expand Down
17 changes: 9 additions & 8 deletions libnixt/lib/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ std::optional<nix::Value> nixt::getField(nix::EvalState &State, nix::Value &V,
return std::nullopt;

nix::Symbol SFiled = State.symbols.create(Field);
if (auto *It = V.attrs->find(SFiled); It != V.attrs->end())
if (auto *It = V.attrs()->find(SFiled); It != V.attrs()->end())
return *It->value;

return std::nullopt;
Expand Down Expand Up @@ -86,11 +86,11 @@ nix::Value &nixt::selectAttr(nix::EvalState &State, nix::Value &V,
State.forceValue(V, nix::noPos);

if (V.type() != nix::ValueType::nAttrs)
throw nix::TypeError("value is not an attrset");
throw nix::TypeError(State, "value is not an attrset");

assert(V.attrs && "nix must allocate non-null attrs!");
auto *Nested = V.attrs->find(Attr);
if (Nested == V.attrs->end())
assert(V.attrs() && "nix must allocate non-null attrs!");
auto *Nested = V.attrs()->find(Attr);
if (Nested == V.attrs()->end())
throw nix::AttrPathNotFound("attrname " + State.symbols[Attr] +
" not found in attrset");

Expand Down Expand Up @@ -145,11 +145,12 @@ nix::Value getSubOptions(nix::EvalState &State, nix::Value &Type) {
nix::Value &GetSubOptions =
selectAttr(State, Type, State.symbols.create("getSubOptions"));

nix::Value EmptyList;
EmptyList.mkList(0);
auto list = State.buildList(0);
auto EmptyList = State.allocValue();
EmptyList->mkList(list);
// Invoke "GetSubOptions"
nix::Value VResult;
State.callFunction(GetSubOptions, EmptyList, VResult, nix::noPos);
State.callFunction(GetSubOptions, *EmptyList, VResult, nix::noPos);
return VResult;
}

Expand Down
4 changes: 2 additions & 2 deletions libnixt/lib/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libnixt_deps = [ nix_expr, nix_main, nix_cmd, boost ]
libnixt_deps = [ nix_expr, nix_flake, nix_main, nix_cmd, boost ]

libnixd_inc = include_directories('../include')

Expand All @@ -19,7 +19,7 @@ pkgconfig.generate(name: 'nixt',
description: 'nix compatible layer',
subdirs: [ 'nixt' ],
libraries: libnixt,
requires: [ 'nix-expr', 'nix-main', 'nix-cmd' ]
requires: [ 'nix-expr', 'nix-main', 'nix-cmd', 'nix-flake' ]
)


Expand Down
1 change: 1 addition & 0 deletions libnixt/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pkgconfig = import('pkgconfig')
nix_main = dependency('nix-main')
nix_expr = dependency('nix-expr')
nix_cmd = dependency('nix-cmd')
nix_flake = dependency('nix-flake')

subdir('lib')
subdir('test')
7 changes: 6 additions & 1 deletion libnixt/test/StateTest.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#include <gtest/gtest.h>

#include <nix/common-eval-args.hh>
#include <nix/eval.hh>
#include <nix/store-api.hh>

namespace nixt {

struct StateTest : testing::Test {
std::unique_ptr<nix::EvalState> State;
StateTest() : State(new nix::EvalState{{}, nix::openStore("dummy://")}) {}
StateTest()
: State(new nix::EvalState{{},
nix::openStore("dummy://"),
nix::fetchSettings,
nix::evalSettings}) {}
};

} // namespace nixt
4 changes: 2 additions & 2 deletions libnixt/test/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace nixt;
namespace {

struct ValueTest : StateTest {
nix::SourcePath cwd() { return State->rootPath(nix::CanonPath::fromCwd()); }
nix::SourcePath cwd() { return State->rootPath("."); }
};

TEST_F(ValueTest, IsOption_neg) {
Expand Down Expand Up @@ -58,7 +58,7 @@ TEST_F(ValueTest, selectAttrPath) {
nix::Value &Kern = selectStringViews(*State, Nested, {"c", "d"});

ASSERT_EQ(Kern.type(), nix::ValueType::nInt);
ASSERT_EQ(Kern.integer, 1);
ASSERT_EQ(Kern.integer(), 1);
}

} // namespace
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ subdir('libnixf/test')
nix_main = dependency('nix-main')
nix_expr = dependency('nix-expr')
nix_cmd = dependency('nix-cmd')
nix_flake = dependency('nix-flake')


subdir('libnixt/lib')
Expand Down
29 changes: 16 additions & 13 deletions nixd/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{ lib
, stdenv
, meson
, ninja
, pkg-config
, nix
, nixf
, nixt
, llvmPackages
, gtest
, boost182
{
lib,
stdenv,
meson,
ninja,
pkg-config,
nix,
nixf,
nixt,
llvmPackages,
gtest,
boost182,
}:

let
Expand All @@ -20,7 +21,10 @@ stdenv.mkDerivation {

src = ../.;

outputs = [ "out" "dev" ];
outputs = [
"out"
"dev"
];

mesonBuildType = "release";

Expand All @@ -45,7 +49,6 @@ stdenv.mkDerivation {

env.CXXFLAGS = "-include ${nix.dev}/include/nix/config.h";


meta = {
mainProgram = "nixd";
description = "Nix language server";
Expand Down
4 changes: 3 additions & 1 deletion nixd/docs/editors/vscodium.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ pkgs ? import <nixpkgs> { } }:
{
pkgs ? import <nixpkgs> { },
}:
with pkgs;
let
codium = vscode-with-extensions.override {
Expand Down
27 changes: 17 additions & 10 deletions nixd/docs/examples/NixOS_Home-Manager/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs@{ self, flake-parts, ... }:
outputs =
inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
debug = true;

Expand All @@ -23,12 +24,15 @@
hostname = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, ... }: {
networking.hostName = "hostname";
environment.systemPackages = with pkgs; [
nixd
];
})
(
{ pkgs, ... }:
{
networking.hostName = "hostname";
environment.systemPackages = with pkgs; [
nixd
];
}
)
];
};
};
Expand All @@ -42,9 +46,12 @@
home.username = "user";
home.homeDirectory = "/home/user";
}
({ pkgs, ... }: {
wayland.windowManager.hyprland.enable = true;
})
(
{ pkgs, ... }:
{
wayland.windowManager.hyprland.enable = true;
}
)
];
};
};
Expand Down
2 changes: 1 addition & 1 deletion nixd/lib/Controller/Definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class WorkerReportedException : std::exception {
llvm::Error E;

public:
WorkerReportedException(llvm::Error E) : E(std::move(E)){};
WorkerReportedException(llvm::Error E) : E(std::move(E)) {};

llvm::Error takeError() { return std::move(E); }
[[nodiscard]] const char *what() const noexcept override {
Expand Down
Loading
Loading