From 7fbd61317edb532e8f58a496198c1474e7d8c0a6 Mon Sep 17 00:00:00 2001 From: khaliddaoud Date: Tue, 24 Dec 2024 07:41:56 +0000 Subject: [PATCH 1/3] pin nixpackage Ver to 23.05 --- .devcontainer/devcontainer.json | 35 +++++++++++++++++++++++++++++++++ default.nix | 18 +++++++++++++++-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..db2c6ed --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/go +{ + "name": "Go", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm", + "features": { + "ghcr.io/devcontainers/features/nix:1": { + "multiUser": true, + "version": "2.11" + }, + "ghcr.io/devcontainers/features/node:1": { + "nodeGypDependencies": true, + "installYarnUsingApt": true, + "version": "lts", + "pnpmVersion": "8.8.0", + "nvmVersion": "0.39" + } + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "root" +} diff --git a/default.nix b/default.nix index 9da7bbb..d4d1011 100644 --- a/default.nix +++ b/default.nix @@ -1,2 +1,16 @@ -{ pkgs ? import {} }: -pkgs.callPackage ./bindings {} +let + nixpkgs = import (fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/nixos-23.05.tar.gz"; # This version uses older GLIBC "https://github.com/nixos/nixpkgs/archive/32dcb45f66c0487e92db8303a798ebc548cadedc.tar.gz"; #which is the newest nixos-23.05 # + sha256 = "sha256:05cbl1k193c9la9xhlz4y6y8ijpb2mkaqrab30zij6z4kqgclsrd"; + }) {}; + +in +nixpkgs.callPackage ./bindings { + inherit (nixpkgs) + lib stdenv abseil-cpp cmake fetchFromGitHub fetchpatch gtest zlib + pkg-config python3 glibc protobuf sqlite libspatialite lua5_3 geos + openssl libpqxx libxml2 lz4 prime-server jemalloc; + gcc12 = nixpkgs.gcc12; + boost179 = nixpkgs.boost179; + curl = nixpkgs.curl; +} \ No newline at end of file From 95e976ded8febc3610bbb19a496ef846a80d5b24 Mon Sep 17 00:00:00 2001 From: khaliddaoud Date: Tue, 24 Dec 2024 08:17:32 +0000 Subject: [PATCH 2/3] Propgate dep from default.nix --- bindings/default.nix | 24 +++++++++++++++++++----- bindings/valhalla/default.nix | 15 +++++++++++++-- result | 1 + 3 files changed, 33 insertions(+), 7 deletions(-) create mode 120000 result diff --git a/bindings/default.nix b/bindings/default.nix index 9624b0d..45a8472 100644 --- a/bindings/default.nix +++ b/bindings/default.nix @@ -1,5 +1,4 @@ -{ nixpkgs ? import {} -, lib +{ lib , stdenv , abseil-cpp , cmake @@ -7,17 +6,32 @@ , fetchpatch , gtest , zlib - +, boost179 # +, protobuf +, sqlite +, libspatialite +, luajit +, geos # downstream dependencies , python3 , ... }: -with nixpkgs; +#with nixpkgs; let - valhallaCustom = (import ./valhalla) { inherit stdenv fetchFromGitHub cmake; }; + valhallaCustom = (import ./valhalla) { inherit + stdenv + fetchFromGitHub + cmake + zlib + boost179 + protobuf + sqlite + libspatialite + luajit + geos; }; protobufCustom = (import ./protobuf) { inherit lib abseil-cpp stdenv fetchFromGitHub cmake fetchpatch gtest zlib python3; }; in stdenv.mkDerivation rec { name = "valhalla-go"; diff --git a/bindings/valhalla/default.nix b/bindings/valhalla/default.nix index 7cf7c5d..8ce4d49 100644 --- a/bindings/valhalla/default.nix +++ b/bindings/valhalla/default.nix @@ -1,6 +1,17 @@ -{ nixpkgs ? import {}, stdenv, fetchFromGitHub, cmake }: +{ stdenv +, fetchFromGitHub +, cmake +, zlib +, boost179 +, protobuf +, sqlite +, libspatialite +, luajit +, geos + +}: + -with nixpkgs; stdenv.mkDerivation rec { name = "valhalla"; diff --git a/result b/result new file mode 120000 index 0000000..181f806 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/h2488lfg9kz3l7s3l3g5kfmg4zkjlk8b-valhalla-go \ No newline at end of file From 3928aa035ee5c5737bce182040410ffe5b2ee711 Mon Sep 17 00:00:00 2001 From: khaliddaoud Date: Wed, 25 Dec 2024 11:37:01 +0000 Subject: [PATCH 3/3] wip --- .gitignore | 3 +++ bindings/default.nix | 16 +++++++++++++- bindings/lz4/default.nix | 41 +++++++++++++++++++++++++++++++++++ bindings/valhalla/default.nix | 8 +++++-- default.nix | 7 ++++-- result | 2 +- 6 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 bindings/lz4/default.nix diff --git a/.gitignore b/.gitignore index 2dcd059..72ec638 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ result/ main +.devcontainer +codebase.md +.aidigestignore \ No newline at end of file diff --git a/bindings/default.nix b/bindings/default.nix index 45a8472..8bc1a05 100644 --- a/bindings/default.nix +++ b/bindings/default.nix @@ -12,6 +12,9 @@ , libspatialite , luajit , geos +, pkg-config +,lz4 + # downstream dependencies , python3 @@ -31,7 +34,11 @@ let sqlite libspatialite luajit - geos; }; + geos + pkg-config + lz4 + ; + }; protobufCustom = (import ./protobuf) { inherit lib abseil-cpp stdenv fetchFromGitHub cmake fetchpatch gtest zlib python3; }; in stdenv.mkDerivation rec { name = "valhalla-go"; @@ -42,19 +49,26 @@ in stdenv.mkDerivation rec { valhallaCustom zlib.static protobufCustom + lz4.bin # Use the main output which contains the libraries + lz4.dev # Include development files like headers ]; buildPhase = '' + c++ \ valhalla_go.cpp \ -fPIC \ -shared \ -o libvalhalla_go.so \ + -L${lz4.dev}/lib \ + -I${lz4.dev}/include \ -Wl,-Bstatic \ -lvalhalla \ -lprotobuf-lite \ -lz \ + -l:liblz4.a \ -Wl,-Bdynamic \ + -Wl,--no-as-needed \ -lpthread ''; diff --git a/bindings/lz4/default.nix b/bindings/lz4/default.nix new file mode 100644 index 0000000..6cc7376 --- /dev/null +++ b/bindings/lz4/default.nix @@ -0,0 +1,41 @@ +{ lib, stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "lz4"; + version = "1.9.4"; + + src = fetchFromGitHub { + owner = "lz4"; + repo = "lz4"; + rev = "v${version}"; + hash = "sha256-YiMCD3vvrG+oxBUghSrCmP2LAfAGZrEaKz0YoaQJhpI="; + }; + + outputs = [ "bin" "out" "dev" ]; + + nativeBuildInputs = [ cmake ]; + + cmakeFlags = [ + "-DBUILD_STATIC_LIBS=ON" + "-DBUILD_SHARED_LIBS=ON" + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" + ]; + + # Use the CMake build system + preConfigure = '' + cd build/cmake + ''; + + postInstall = '' + mkdir -p $dev/lib + cp lib/liblz4.a $dev/lib || true + cp liblz4.a $dev/lib || true + ''; + + meta = with lib; { + description = "Extremely fast compression algorithm"; + homepage = "https://lz4.github.io/lz4/"; + license = with licenses; [ bsd2 gpl2Plus ]; + platforms = platforms.all; + }; +} \ No newline at end of file diff --git a/bindings/valhalla/default.nix b/bindings/valhalla/default.nix index 8ce4d49..6d92883 100644 --- a/bindings/valhalla/default.nix +++ b/bindings/valhalla/default.nix @@ -8,6 +8,8 @@ , libspatialite , luajit , geos +, pkg-config +, lz4 }: @@ -19,8 +21,8 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "valhalla"; repo = "valhalla"; - rev = "3.3.0"; - sha256 = "honnvgmT1u26vv2AdtLfHou7B640PXaV3s0XXNkd/QE="; + rev = "3.5.1"; + sha256 = "sha256-v/EwoJA1j8PuF9jOsmxQL6i+MT0rXbyLUE4HvBHUWDo="; fetchSubmodules = true; }; @@ -47,6 +49,8 @@ stdenv.mkDerivation rec { libspatialite luajit geos + pkg-config + lz4 ]; # install necessary headers diff --git a/default.nix b/default.nix index d4d1011..9168cc4 100644 --- a/default.nix +++ b/default.nix @@ -4,13 +4,16 @@ let sha256 = "sha256:05cbl1k193c9la9xhlz4y6y8ijpb2mkaqrab30zij6z4kqgclsrd"; }) {}; +lz4_custom = nixpkgs.callPackage ./bindings/lz4 {}; + in nixpkgs.callPackage ./bindings { inherit (nixpkgs) lib stdenv abseil-cpp cmake fetchFromGitHub fetchpatch gtest zlib pkg-config python3 glibc protobuf sqlite libspatialite lua5_3 geos - openssl libpqxx libxml2 lz4 prime-server jemalloc; + openssl libpqxx libxml2 prime-server jemalloc; gcc12 = nixpkgs.gcc12; boost179 = nixpkgs.boost179; - curl = nixpkgs.curl; + lz4 = lz4_custom; + } \ No newline at end of file diff --git a/result b/result index 181f806..5815fbf 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/h2488lfg9kz3l7s3l3g5kfmg4zkjlk8b-valhalla-go \ No newline at end of file +/nix/store/55dx9p4lni9jyj8w3hg4p28ayyhrf1kq-valhalla-go \ No newline at end of file