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

Support Nix 2.17 #1296

Merged
merged 3 commits into from
Aug 23, 2023
Merged

Support Nix 2.17 #1296

merged 3 commits into from
Aug 23, 2023

Conversation

lheckemann
Copy link
Member

cc @Ericson2314 who authored the API changes, to make sure I'm not doing something really silly here.

I don't think it's nice to use the WriteConn/ReadConn and the FdSinks wrapped by them simultaneously, but I'm guessing the flushes are important -- and they can't be performed through the WriteConn because not all Sinks are flushable.

@Ericson2314
Copy link
Member

@lheckemann You did it correctly. The flushing nuscience is indeed a symptom of this code being spaghetti-ish, making conceptual operations with low-level serialization details too much

#1180 and then eventually https://github.com/NixOS/nix/pull/6134/files would solve this problem, separating concerns so the "serialization on the inside, misc IO like flushing on the outside" structure was more clear.

@Ma27
Copy link
Member

Ma27 commented Aug 6, 2023

Successfully deployed my Hydra with Nix 2.17 and this change and so far, everything works fine.

One problem though: in my deployment I'm not using nix from Hydra's flake input, but nixVersions.nix_2_17 from nixpkgs. Turns out that Hydra fails to link against this if --enable-lto is specified for nixVersions.nix_2_17:

hydra-0.1.20230804.DIRTY> /nix/store/7q1b1bsmxi91zci6g8714rcljl620y7f-bash-5.2-p15/bin/bash ../../libtool  --tag=CXX   --mode=link g++ -std=c++2a -I/nix/store/2wc8v442wwy4zqcnwr1l62v1vp9da2sq-nix-2.17.0-dev/include/nix -I/nix/store/ksqbb3np13si616y71y1bbxyyhqcm0pr-boehm-gc-8.2.2-dev/include -Wall -I ../libhydra -Wno-deprecated-declarations -g -O2 -include nix/config.h   -o hydra-queue-runner hydra_queue_runner-hydra-queue-runner.o hydra_queue_runner-queue-monitor.o hydra_queue_runner-dispatcher.o hydra_queue_runner-builder.o hydra_queue_runner-build-result.o hydra_queue_runner-build-remote.o hydra_queue_runner-nar-extractor.o -L/nix/store/11vbrp5bsvh31ddb8vxl82ryyb1rqq2z-nix-2.17.0/lib -L/nix/store/3a9r1dwgnszi7x9vybsx8y8mhhl8s0n0-boehm-gc-8.2.2/lib -lnixmain -lnixexpr -lgc -lpthread -ldl -lnixstore -lnixutil -lpqxx -lprometheus-cpp-pull -lprometheus-cpp-core 
hydra-0.1.20230804.DIRTY> libtool: link: g++ -std=c++2a -I/nix/store/2wc8v442wwy4zqcnwr1l62v1vp9da2sq-nix-2.17.0-dev/include/nix -I/nix/store/ksqbb3np13si616y71y1bbxyyhqcm0pr-boehm-gc-8.2.2-dev/include -Wall -I ../libhydra -Wno-deprecated-declarations -g -O2 -include nix/config.h -o hydra-queue-runner hydra_queue_runner-hydra-queue-runner.o hydra_queue_runner-queue-monitor.o hydra_queue_runner-dispatcher.o hydra_queue_runner-builder.o hydra_queue_runner-build-result.o hydra_queue_runner-build-remote.o hydra_queue_runner-nar-extractor.o  -L/nix/store/11vbrp5bsvh31ddb8vxl82ryyb1rqq2z-nix-2.17.0/lib -L/nix/store/3a9r1dwgnszi7x9vybsx8y8mhhl8s0n0-boehm-gc-8.2.2/lib -lnixmain -lnixexpr /nix/store/3a9r1dwgnszi7x9vybsx8y8mhhl8s0n0-boehm-gc-8.2.2/lib/libgc.so -lpthread -ldl -lnixstore -lnixutil /nix/store/cwjk8rvgpvi8dd3ga76a4z0wca2s5vlg-libpqxx-7.7.0/lib/libpqxx.so -lprometheus-cpp-pull -lprometheus-cpp-core -Wl,-rpath -Wl,/nix/store/3a9r1dwgnszi7x9vybsx8y8mhhl8s0n0-boehm-gc-8.2.2/lib -Wl,-rpath -Wl,/nix/store/cwjk8rvgpvi8dd3ga76a4z0wca2s5vlg-libpqxx-7.7.0/lib -Wl,-rpath -Wl,/nix/store/3a9r1dwgnszi7x9vybsx8y8mhhl8s0n0-boehm-gc-8.2.2/lib -Wl,-rpath -Wl,/nix/store/cwjk8rvgpvi8dd3ga76a4z0wca2s5vlg-libpqxx-7.7.0/lib
hydra-0.1.20230804.DIRTY> /nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: hydra_queue_runner-build-remote.o: in function `void nix::WorkerProto::write<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > >(nix::Store const&, nix::WorkerProto::WriteConn, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > const&)':
hydra-0.1.20230804.DIRTY> /nix/store/2wc8v442wwy4zqcnwr1l62v1vp9da2sq-nix-2.17.0-dev/include/nix/worker-protocol.hh:112: undefined reference to `nix::WorkerProto::Serialise<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > >::write(nix::Store const&, nix::WorkerProto::WriteConn, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > const&)'
hydra-0.1.20230804.DIRTY> /nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: hydra_queue_runner-build-remote.o: in function `State::buildRemote(nix::ref<nix::Store>, std::shared_ptr<Machine>, std::shared_ptr<Step>, unsigned int, unsigned int, unsigned int, RemoteResult&, std::shared_ptr<State::ActiveStep>, std::function<void (StepState)>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, NarMemberData, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, NarMemberData> > >&)':
hydra-0.1.20230804.DIRTY> /build/source/src/hydra-queue-runner/build-remote.cc:127: undefined reference to `nix::WorkerProto::Serialise<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > >::read(nix::Store const&, nix::WorkerProto::ReadConn)'
hydra-0.1.20230804.DIRTY> /nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: /build/source/src/hydra-queue-runner/build-remote.cc:375: undefined reference to `nix::WorkerProto::Serialise<std::map<nix::DrvOutput, nix::Realisation, std::less<nix::DrvOutput>, std::allocator<std::pair<nix::DrvOutput const, nix::Realisation> > > >::read(nix::Store const&, nix::WorkerProto::ReadConn)'
hydra-0.1.20230804.DIRTY> /nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: hydra_queue_runner-build-remote.o: in function `void nix::WorkerProto::write<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > >(nix::Store const&, nix::WorkerProto::WriteConn, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > const&)':
hydra-0.1.20230804.DIRTY> /nix/store/2wc8v442wwy4zqcnwr1l62v1vp9da2sq-nix-2.17.0-dev/include/nix/worker-protocol.hh:112: undefined reference to `nix::WorkerProto::Serialise<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > >::write(nix::Store const&, nix::WorkerProto::WriteConn, std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > const&)'
hydra-0.1.20230804.DIRTY> /nix/store/dx8hynidprz3kf4ngcjipnwaxp6h229f-binutils-2.40/bin/ld: hydra_queue_runner-build-remote.o: in function `State::buildRemote(nix::ref<nix::Store>, std::shared_ptr<Machine>, std::shared_ptr<Step>, unsigned int, unsigned int, unsigned int, RemoteResult&, std::shared_ptr<State::ActiveStep>, std::function<void (StepState)>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, NarMemberData, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, NarMemberData> > >&)':
hydra-0.1.20230804.DIRTY> /build/source/src/hydra-queue-runner/build-remote.cc:458: undefined reference to `nix::WorkerProto::Serialise<std::set<nix::StorePath, std::less<nix::StorePath>, std::allocator<nix::StorePath> > >::read(nix::Store const&, nix::WorkerProto::ReadConn)'
hydra-0.1.20230804.DIRTY> collect2: error: ld returned 1 exit status
hydra-0.1.20230804.DIRTY> make[3]: *** [Makefile:435: hydra-queue-runner] Error 1
hydra-0.1.20230804.DIRTY> make[3]: Leaving directory '/build/source/src/hydra-queue-runner'
hydra-0.1.20230804.DIRTY> make[2]: *** [Makefile:363: all-recursive] Error 1
hydra-0.1.20230804.DIRTY> make[2]: Leaving directory '/build/source/src'
hydra-0.1.20230804.DIRTY> make[1]: *** [Makefile:422: all-recursive] Error 1
hydra-0.1.20230804.DIRTY> make[1]: Leaving directory '/build/source'
hydra-0.1.20230804.DIRTY> make: *** [Makefile:350: all] Error 2

This can also be reproduced with the nixos/nix flake when on the PR's (at rev b23431a) branch with the following diff:

diff --git a/flake.nix b/flake.nix
index 7e7d50e2..d83a18e0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -14,7 +14,7 @@
 
       pkgsBySystem = forEachSystem (system: import nixpkgs {
         inherit system;
-        overlays = [ self.overlays.default nix.overlays.default ];
+        overlays = [ nix.overlays.default self.overlays.default ];
       });
 
       # NixOS configuration used for VM tests.
@@ -40,6 +40,9 @@
 
       # A Nixpkgs overlay that provides a 'hydra' package.
       overlays.default = final: prev: {
+        nix = prev.nix.overrideAttrs ({ configureFlags ? [], ... }: {
+          configureFlags = configureFlags ++ [ "--enable-lto" ];
+        });
 
         # Add LDAP dependencies that aren't currently found within nixpkgs.
         perlPackages = prev.perlPackages // {

Will also file a bug against Nix @Ericson2314 .

@edolstra edolstra merged commit 00d3087 into NixOS:master Aug 23, 2023
1 check passed
@edolstra edolstra deleted the nix-2.17 branch August 23, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants