From 6b9e09f9bd0fd32771c3f6f31874e8ca4310bb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 23 Nov 2024 10:01:53 +0100 Subject: [PATCH 1/2] fix compilation with nix 2.25 --- flake.lock | 6 +++--- flake.nix | 2 +- libnixt/test/Value.cpp | 2 +- nixd/lib/Eval/AttrSetProvider.cpp | 8 ++++---- nixd/lspserver/include/lspserver/Protocol.h | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index c2be67aca..5db4ddd3a 100644 --- a/flake.lock +++ b/flake.lock @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1730831018, - "narHash": "sha256-2S0HwIFRxYp+afuoFORcZA9TjryAf512GmE0MTfEOPU=", + "lastModified": 1732617236, + "narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8c4dc69b9732f6bbe826b5fbb32184987520ff26", + "rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 719b49369..14fb4363b 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ callPackage stdenv ; - nix = nixVersions.nix_2_24; + nix = nixVersions.nix_2_25; llvmPackages = llvmPackages_16; nixf = callPackage ./libnixf { }; nixt = callPackage ./libnixt { inherit nix; }; diff --git a/libnixt/test/Value.cpp b/libnixt/test/Value.cpp index 30a2b8536..ab95a5a78 100644 --- a/libnixt/test/Value.cpp +++ b/libnixt/test/Value.cpp @@ -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(), nix::NixInt{1}); } } // namespace diff --git a/nixd/lib/Eval/AttrSetProvider.cpp b/nixd/lib/Eval/AttrSetProvider.cpp index dd01a23f7..8acc933e3 100644 --- a/nixd/lib/Eval/AttrSetProvider.cpp +++ b/nixd/lib/Eval/AttrSetProvider.cpp @@ -54,8 +54,8 @@ std::optional locationOf(nix::PosTable &PTable, nix::Value &V) { return std::nullopt; Position LPos = { - .line = static_cast(NixPos.line - 1), - .character = static_cast(NixPos.column - 1), + .line = static_cast(NixPos.line - 1), + .character = static_cast(NixPos.column - 1), }; return Location{ @@ -86,8 +86,8 @@ void fillUnsafeGetAttrPosLocation(nix::EvalState &State, nix::Value &V, Column.type() == nix::ValueType::nInt) { // Nix position starts from "1" however lsp starts from zero. - lspserver::Position Pos = {static_cast(Line.integer()) - 1, - static_cast(Column.integer()) - 1}; + lspserver::Position Pos = {static_cast(Line.integer()) - 1, + static_cast(Column.integer()) - 1}; Loc.range = {Pos, Pos}; } } diff --git a/nixd/lspserver/include/lspserver/Protocol.h b/nixd/lspserver/include/lspserver/Protocol.h index 05959073c..400042759 100644 --- a/nixd/lspserver/include/lspserver/Protocol.h +++ b/nixd/lspserver/include/lspserver/Protocol.h @@ -127,12 +127,12 @@ bool fromJSON(const llvm::json::Value &, VersionedTextDocumentIdentifier &, struct Position { /// Line position in a document (zero-based). - int line = 0; + long int line = 0; /// Character offset on a line in a document (zero-based). /// WARNING: this is in UTF-16 codepoints, not bytes or characters! /// Use the functions in SourceCode.h to construct/interpret Positions. - int character = 0; + long int character = 0; friend bool operator==(const Position &LHS, const Position &RHS) { return std::tie(LHS.line, LHS.character) == From 1dfc7f8609fafd826d6aec01feedf171832706ea Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sun, 24 Nov 2024 02:19:16 +0800 Subject: [PATCH 2/2] fixup: `long int` -> `int64_t` on macOS `int64_t` is defined to `long long int` (not `long int`), however LSP's JSON library (by llvm-project) only supports `std::int64_t` --- nixd/lib/Eval/AttrSetProvider.cpp | 8 ++++---- nixd/lspserver/include/lspserver/Protocol.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nixd/lib/Eval/AttrSetProvider.cpp b/nixd/lib/Eval/AttrSetProvider.cpp index 8acc933e3..40aa14c53 100644 --- a/nixd/lib/Eval/AttrSetProvider.cpp +++ b/nixd/lib/Eval/AttrSetProvider.cpp @@ -54,8 +54,8 @@ std::optional locationOf(nix::PosTable &PTable, nix::Value &V) { return std::nullopt; Position LPos = { - .line = static_cast(NixPos.line - 1), - .character = static_cast(NixPos.column - 1), + .line = static_cast(NixPos.line - 1), + .character = static_cast(NixPos.column - 1), }; return Location{ @@ -86,8 +86,8 @@ void fillUnsafeGetAttrPosLocation(nix::EvalState &State, nix::Value &V, Column.type() == nix::ValueType::nInt) { // Nix position starts from "1" however lsp starts from zero. - lspserver::Position Pos = {static_cast(Line.integer()) - 1, - static_cast(Column.integer()) - 1}; + lspserver::Position Pos = {static_cast(Line.integer()) - 1, + static_cast(Column.integer()) - 1}; Loc.range = {Pos, Pos}; } } diff --git a/nixd/lspserver/include/lspserver/Protocol.h b/nixd/lspserver/include/lspserver/Protocol.h index 400042759..dffe1fcb7 100644 --- a/nixd/lspserver/include/lspserver/Protocol.h +++ b/nixd/lspserver/include/lspserver/Protocol.h @@ -127,12 +127,12 @@ bool fromJSON(const llvm::json::Value &, VersionedTextDocumentIdentifier &, struct Position { /// Line position in a document (zero-based). - long int line = 0; + int64_t line = 0; /// Character offset on a line in a document (zero-based). /// WARNING: this is in UTF-16 codepoints, not bytes or characters! /// Use the functions in SourceCode.h to construct/interpret Positions. - long int character = 0; + int64_t character = 0; friend bool operator==(const Position &LHS, const Position &RHS) { return std::tie(LHS.line, LHS.character) ==