From b8faa837429cbcb4f950248571c761c98895e7cd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 May 2022 13:24:04 +0200 Subject: [PATCH 1/4] HttpBinaryCacheStore::getFile(): Don't throw an exception This violates the noexcept specification. Fixes #6445. --- src/libstore/http-binary-cache-store.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc index 3cb5efdbf..73bcd6e81 100644 --- a/src/libstore/http-binary-cache-store.cc +++ b/src/libstore/http-binary-cache-store.cc @@ -161,7 +161,12 @@ protected: void getFile(const std::string & path, Callback> callback) noexcept override { - checkEnabled(); + try { + checkEnabled(); + } catch (...) { + callback.rethrow(); + return; + } auto request(makeRequest(path)); From 6378f0bb328437de759f7ed8405fcafbb3bcac54 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 May 2022 13:27:13 +0200 Subject: [PATCH 2/4] RemoteStore::queryRealisationUncached(): Fix potential noexcept violation --- src/libstore/remote-store.cc | 56 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 14aeba75c..bc36aef5d 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -718,36 +718,34 @@ void RemoteStore::registerDrvOutput(const Realisation & info) void RemoteStore::queryRealisationUncached(const DrvOutput & id, Callback> callback) noexcept { - auto conn(getConnection()); - - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) { - warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4"); - try { - callback(nullptr); - } catch (...) { return callback.rethrow(); } - } - - conn->to << wopQueryRealisation; - conn->to << id.to_string(); - conn.processStderr(); - - auto real = [&]() -> std::shared_ptr { - if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { - auto outPaths = worker_proto::read( - *this, conn->from, Phantom> {}); - if (outPaths.empty()) - return nullptr; - return std::make_shared(Realisation { .id = id, .outPath = *outPaths.begin() }); - } else { - auto realisations = worker_proto::read( - *this, conn->from, Phantom> {}); - if (realisations.empty()) - return nullptr; - return std::make_shared(*realisations.begin()); - } - }(); - try { + auto conn(getConnection()); + + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 27) { + warn("the daemon is too old to support content-addressed derivations, please upgrade it to 2.4"); + return callback(nullptr); + } + + conn->to << wopQueryRealisation; + conn->to << id.to_string(); + conn.processStderr(); + + auto real = [&]() -> std::shared_ptr { + if (GET_PROTOCOL_MINOR(conn->daemonVersion) < 31) { + auto outPaths = worker_proto::read( + *this, conn->from, Phantom> {}); + if (outPaths.empty()) + return nullptr; + return std::make_shared(Realisation { .id = id, .outPath = *outPaths.begin() }); + } else { + auto realisations = worker_proto::read( + *this, conn->from, Phantom> {}); + if (realisations.empty()) + return nullptr; + return std::make_shared(*realisations.begin()); + } + }(); + callback(std::shared_ptr(real)); } catch (...) { return callback.rethrow(); } } From 948515efb775c22df5a2585443a0c7f86d2dc64d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 May 2022 13:35:28 +0200 Subject: [PATCH 3/4] Set meta.platforms 'nix-serve' in nixpkgs expects the nix package to set this. --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 77b016ff0..6e0e4d423 100644 --- a/flake.nix +++ b/flake.nix @@ -380,6 +380,7 @@ postUnpack = "sourceRoot=$sourceRoot/perl"; }; + meta.platforms = systems; }; lowdown-nix = with final; currentStdenv.mkDerivation rec { From 452dba510de2f500eae35bbb9dfb5ff825ca0351 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 May 2022 14:01:35 +0200 Subject: [PATCH 4/4] Mark nix-perl as a Perl module The call to perl.withPackages in nix-serve expects this. --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 6e0e4d423..1aa4c4479 100644 --- a/flake.nix +++ b/flake.nix @@ -348,7 +348,7 @@ strictDeps = true; - passthru.perl-bindings = with final; currentStdenv.mkDerivation { + passthru.perl-bindings = with final; perl.pkgs.toPerlModule (currentStdenv.mkDerivation { name = "nix-perl-${version}"; src = self; @@ -378,7 +378,7 @@ enableParallelBuilding = true; postUnpack = "sourceRoot=$sourceRoot/perl"; - }; + }); meta.platforms = systems; };