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

PIN Nix Dependencies #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
result/
main
.devcontainer
codebase.md
.aidigestignore
36 changes: 32 additions & 4 deletions bindings/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
{ nixpkgs ? import <nixpkgs> {}
, lib
{ lib
, stdenv
, abseil-cpp
, cmake
, fetchFromGitHub
, fetchpatch
, gtest
, zlib
, boost179 #
, protobuf
, sqlite
, libspatialite
, luajit
, geos
, pkg-config
,lz4

# 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
pkg-config
lz4
;
};
protobufCustom = (import ./protobuf) { inherit lib abseil-cpp stdenv fetchFromGitHub cmake fetchpatch gtest zlib python3; };
in stdenv.mkDerivation rec {
name = "valhalla-go";
Expand All @@ -28,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
'';

Expand Down
41 changes: 41 additions & 0 deletions bindings/lz4/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
23 changes: 19 additions & 4 deletions bindings/valhalla/default.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{ nixpkgs ? import <nixpkgs> {}, stdenv, fetchFromGitHub, cmake }:
{ stdenv
, fetchFromGitHub
, cmake
, zlib
, boost179
, protobuf
, sqlite
, libspatialite
, luajit
, geos
, pkg-config
, lz4

}:


with nixpkgs;

stdenv.mkDerivation rec {
name = "valhalla";

src = fetchFromGitHub {
owner = "valhalla";
repo = "valhalla";
rev = "3.3.0";
sha256 = "honnvgmT1u26vv2AdtLfHou7B640PXaV3s0XXNkd/QE=";
rev = "3.5.1";
sha256 = "sha256-v/EwoJA1j8PuF9jOsmxQL6i+MT0rXbyLUE4HvBHUWDo=";
fetchSubmodules = true;
};

Expand All @@ -36,6 +49,8 @@ stdenv.mkDerivation rec {
libspatialite
luajit
geos
pkg-config
lz4
];

# install necessary headers
Expand Down
21 changes: 19 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
{ pkgs ? import <nixpkgs> {} }:
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";
}) {};

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 prime-server jemalloc;
gcc12 = nixpkgs.gcc12;
boost179 = nixpkgs.boost179;
lz4 = lz4_custom;

}
1 change: 1 addition & 0 deletions result