diff --git a/nix/c-ares-cmake.nix b/nix/c-ares-cmake.nix new file mode 100644 --- /dev/null +++ b/nix/c-ares-cmake.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, c-ares, writeTextFile }: + +let + extension = if stdenv.hostPlatform.isStatic then ".a" else stdenv.hostPlatform.extensions.sharedLibrary; + buildType = if stdenv.hostPlatform.isStatic then "STATIC" else "SHARED"; + buildTypeLower = if stdenv.hostPlatform.isStatic then "static" else "shared"; +in writeTextFile { + name = "c-ares-cmake-config"; + destination = "/lib/cmake/c-ares/c-ares-config.cmake"; + text = '' + set(c-ares_INCLUDE_DIR "${c-ares}/include") + set(c-ares_LIBRARY c-ares::cares) + add_library(c-ares::cares ${buildType} IMPORTED) + set_target_properties(c-ares::cares PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${c-ares}/include" + ) + set_property(TARGET c-ares::cares APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(c-ares::cares PROPERTIES + IMPORTED_LOCATION_RELEASE "${c-ares}/lib/libcares${extension}" + IMPORTED_SONAME_RELEASE "libcares${extension}" + ) + add_library(c-ares::cares_${buildTypeLower} INTERFACE IMPORTED) + set_target_properties(c-ares::cares_${buildTypeLower} PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares") + set(c-ares_${buildType}_LIBRARY c-ares::cares_${buildTypeLower}) + ''; +} diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix --- a/nix/dev-shell.nix +++ b/nix/dev-shell.nix @@ -6,6 +6,7 @@ , aws-sdk-cpp , better-prompt , boost +, c-ares_cmake-config , cargo , cmake , cmake-format @@ -65,6 +66,7 @@ # Tunnelbroker + CMake amqp-cpp + c-ares_cmake-config cryptopp cmake cmake-format # linting diff --git a/nix/overlay.nix b/nix/overlay.nix --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -43,6 +43,11 @@ better-prompt = prev.callPackage ./better-prompt.nix { }; + # Vendored version of https://github.com/NixOS/nixpkgs/pull/191120 + # and https://github.com/NixOS/nixpkgs/pull/191123 + # Can remove after upstream PRs gets merged and nixos-unstable channel updates + c-ares_cmake-config = final.callPackage ./c-ares-cmake.nix { }; + protobuf_3_15_cmake = prev.callPackage ./protobuf_3_15.nix { }; devShell = final.callPackage ./dev-shell.nix { };