Skip to content

Commit 1cf9ec0

Browse files
Mic92inclyc
andauthored
flake/deps: nix 2.19 -> 2.24 (#613)
Co-authored-by: Yingchi Long <i@lyc.dev>
1 parent 20290ee commit 1cf9ec0

File tree

20 files changed

+109
-79
lines changed

20 files changed

+109
-79
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
callPackage
3434
stdenv
3535
;
36-
nix = nixVersions.nix_2_19;
36+
nix = nixVersions.nix_2_24;
3737
llvmPackages = llvmPackages_16;
3838
nixf = callPackage ./libnixf { };
3939
nixt = callPackage ./libnixt { inherit nix; };

libnixt/default.nix

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
{ lib
2-
, stdenv
3-
, meson
4-
, ninja
5-
, pkg-config
6-
, nix
7-
, gtest
8-
, boost182
1+
{
2+
lib,
3+
stdenv,
4+
meson,
5+
ninja,
6+
pkg-config,
7+
nix,
8+
gtest,
9+
boost182,
910
}:
1011

1112
stdenv.mkDerivation {
@@ -14,7 +15,10 @@ stdenv.mkDerivation {
1415

1516
src = ../.;
1617

17-
outputs = [ "out" "dev" ];
18+
outputs = [
19+
"out"
20+
"dev"
21+
];
1822

1923
mesonBuildType = "release";
2024

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

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

39-
4043
meta = {
4144
mainProgram = "nixt";
4245
description = "Nix language frontend, parser & semantic analysis";

libnixt/include/nixt/InitEval.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#pragma once
22

3+
#include <nix/common-eval-args.hh>
4+
#include <nix/eval-gc.hh>
5+
#include <nix/eval-settings.hh>
36
#include <nix/eval.hh>
7+
#include <nix/flake/flake.hh>
8+
#include <nix/plugin.hh>
49
#include <nix/shared.hh>
510
#include <nix/store-api.hh>
611

@@ -9,6 +14,7 @@ namespace nixt {
914
inline void initEval() {
1015
nix::initNix();
1116
nix::initLibStore();
17+
nix::flake::initLib(nix::flakeSettings);
1218
nix::initPlugins();
1319
nix::initGC();
1420
}

libnixt/lib/Flake.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ void nixt::callDirtyFlake(EvalState &State, std::string_view Src,
147147
nix::Value &VRes) {
148148

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

152152
auto *VFlakeCompat = State.allocValue();
153153

154-
nix::Expr *EFlakeCompat = State.parseExprFromString(
155-
FlakeCompat, State.rootPath(nix::CanonPath::fromCwd()));
154+
nix::Expr *EFlakeCompat =
155+
State.parseExprFromString(FlakeCompat, State.rootPath("."));
156156
State.eval(EFlakeCompat, *VFlakeCompat);
157157

158158
State.callFunction(*VFlakeCompat, *VSrc, VRes, noPos);

libnixt/lib/Value.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ std::optional<nix::Value> nixt::getField(nix::EvalState &State, nix::Value &V,
1414
return std::nullopt;
1515

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

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

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

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

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

148-
nix::Value EmptyList;
149-
EmptyList.mkList(0);
148+
auto list = State.buildList(0);
149+
auto EmptyList = State.allocValue();
150+
EmptyList->mkList(list);
150151
// Invoke "GetSubOptions"
151152
nix::Value VResult;
152-
State.callFunction(GetSubOptions, EmptyList, VResult, nix::noPos);
153+
State.callFunction(GetSubOptions, *EmptyList, VResult, nix::noPos);
153154
return VResult;
154155
}
155156

libnixt/lib/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
libnixt_deps = [ nix_expr, nix_main, nix_cmd, boost ]
1+
libnixt_deps = [ nix_expr, nix_flake, nix_main, nix_cmd, boost ]
22

33
libnixd_inc = include_directories('../include')
44

@@ -19,7 +19,7 @@ pkgconfig.generate(name: 'nixt',
1919
description: 'nix compatible layer',
2020
subdirs: [ 'nixt' ],
2121
libraries: libnixt,
22-
requires: [ 'nix-expr', 'nix-main', 'nix-cmd' ]
22+
requires: [ 'nix-expr', 'nix-main', 'nix-cmd', 'nix-flake' ]
2323
)
2424

2525

libnixt/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pkgconfig = import('pkgconfig')
1414
nix_main = dependency('nix-main')
1515
nix_expr = dependency('nix-expr')
1616
nix_cmd = dependency('nix-cmd')
17+
nix_flake = dependency('nix-flake')
1718

1819
subdir('lib')
1920
subdir('test')

libnixt/test/StateTest.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
#include <gtest/gtest.h>
22

3+
#include <nix/common-eval-args.hh>
34
#include <nix/eval.hh>
45
#include <nix/store-api.hh>
56

67
namespace nixt {
78

89
struct StateTest : testing::Test {
910
std::unique_ptr<nix::EvalState> State;
10-
StateTest() : State(new nix::EvalState{{}, nix::openStore("dummy://")}) {}
11+
StateTest()
12+
: State(new nix::EvalState{{},
13+
nix::openStore("dummy://"),
14+
nix::fetchSettings,
15+
nix::evalSettings}) {}
1116
};
1217

1318
} // namespace nixt

libnixt/test/Value.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using namespace nixt;
77
namespace {
88

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

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

6060
ASSERT_EQ(Kern.type(), nix::ValueType::nInt);
61-
ASSERT_EQ(Kern.integer, 1);
61+
ASSERT_EQ(Kern.integer(), 1);
6262
}
6363

6464
} // namespace

0 commit comments

Comments
 (0)