From f9630fbfc57b374855cca44a7a635b41ac71bb6f 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] fix compilation with nix 2.25 --- flake.lock | 8 ++++---- flake.nix | 7 +++++-- libnixt/test/Value.cpp | 2 +- nixd/lib/Eval/AttrSetProvider.cpp | 8 ++++---- nixd/lspserver/include/lspserver/Protocol.h | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index c2be67aca..24af11d6e 100644 --- a/flake.lock +++ b/flake.lock @@ -35,16 +35,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1730831018, - "narHash": "sha256-2S0HwIFRxYp+afuoFORcZA9TjryAf512GmE0MTfEOPU=", + "lastModified": 1732310578, + "narHash": "sha256-kk5Cv6wB20ujrB8w2ny5Co20xCHYOjUSyk2VRuP0sZw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8c4dc69b9732f6bbe826b5fbb32184987520ff26", + "rev": "72f68849662579c8d4e5d13bd4d400723a1d8edd", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixpkgs-unstable", + "ref": "nixos-unstable-small", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 719b49369..62aeae67f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,9 @@ { inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + # TODO: switch back once nix 2.25 hits nixpkgs-unstable + # https://nixpk.gs/pr-tracker.html?pr=355350 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; + #nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; @@ -33,7 +36,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..c597b41cc 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) ==