From 26a610c1a33b834f5e7575d1c9273c56f7d35f80 Mon Sep 17 00:00:00 2001 From: Tasia Iso Date: Sun, 23 Feb 2025 19:10:00 +0100 Subject: [PATCH] build(nix): add a patch to make viz1090 use the packaged mapdata --- nix/viz1090.nix | 123 +++++++++++++++++++++++++++++++----------------- 1 file changed, 79 insertions(+), 44 deletions(-) diff --git a/nix/viz1090.nix b/nix/viz1090.nix index 4d82ffd..56ee5e6 100644 --- a/nix/viz1090.nix +++ b/nix/viz1090.nix @@ -5,54 +5,89 @@ fetchFromGitea, self, system, -}: -stdenv.mkDerivation rec { - pname = "viz1090"; - version = "0.1.0"; +}: let + viz1090-mapdata = self.packages.${system}.viz1090-mapdata; +in + stdenv.mkDerivation rec { + pname = "viz1090"; + version = "0.1.0"; - src = fetchFromGitea { - domain = "git.vulpecula.zone"; - owner = "tasiaiso"; - repo = pname; - rev = "d1f53019b22a9e605506bed90fcffcdc5f7e6186"; - hash = "sha256-gtv0u7o+5fqVgA0CHDWdZr0h9A1Nbky1+okHvSv1cVU="; - }; + src = fetchFromGitea { + domain = "git.vulpecula.zone"; + owner = "tasiaiso"; + repo = pname; + rev = "1922324b40f84fd449cec3fbfdade8aa33597bf6"; + hash = "sha256-bPVFKbGtPXOitzzHb3yJ6XW3fRh8PF/7kfP7EJkJX3c="; + }; - nativeBuildInputs = with pkgs; [ - rtl-sdr-librtlsdr - SDL2 - SDL2_ttf - SDL2_gfx - gdal - git - ]; + nativeBuildInputs = with pkgs; [ + rtl-sdr-librtlsdr + SDL2 + SDL2_ttf + SDL2_gfx + gdal + git + ]; - buildInputs = [ - self.packages.${system}.viz1090-mapdata - ]; + buildInputs = [ + viz1090-mapdata + ]; - buildPhase = '' - echo "--- a/Makefile - +++ b/Makefile - @@ -3,7 +3,7 @@ - # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local - # + buildPhase = '' + echo "diff --git a/Makefile b/Makefile +index 5e60779..d5b30ab 100644 +--- a/Makefile ++++ b/Makefile +@@ -3,7 +3,7 @@ + # sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local + # + +-CXXFLAGS=-O2 -std=c++11 -g ++CXXFLAGS=-O2 -std=c++11 -g -I ${pkgs.SDL2.dev}/include/SDL2/ + LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -g + CXX=g++ + +diff --git a/Map.cpp b/Map.cpp +index cd798ec..c5736bd 100644 +--- a/Map.cpp ++++ b/Map.cpp +@@ -189,7 +189,7 @@ std::vector Map::getLines(float screen_lat_min, float screen_lat_max, flo + Map::Map() { + FILE *fileptr; + +- if((fileptr = fopen(\"mapdata.bin\", \"rb\"))) { ++ if((fileptr = fopen(\"${viz1090-mapdata}/mapdata.bin\", \"rb\"))) { + + + fseek(fileptr, 0, SEEK_END); +@@ -255,7 +255,7 @@ Map::Map() { + // + + +- if((fileptr = fopen(\"airportdata.bin\", \"rb\"))) { ++ if((fileptr = fopen(\"${viz1090-mapdata}/airportdata.bin\", \"rb\"))) { + fseek(fileptr, 0, SEEK_END); + airportPoints_count = ftell(fileptr) / sizeof(float); + rewind(fileptr); +@@ -350,7 +350,7 @@ Map::Map() { + + infile.close(); + +- infile.open(\"airportnames\"); ++ infile.open(\"${viz1090-mapdata}/airportnames\"); + + + while (std::getline(infile, line)) + + " | git apply - - -CXXFLAGS=-O2 -std=c++11 -g - +CXXFLAGS=-O2 -std=c++11 -g -I ${pkgs.SDL2.dev}/include/SDL2/ - LIBS= -lm -lSDL2 -lSDL2_ttf -lSDL2_gfx -g - CXX=g++ - " | git apply - + cat Map.cpp | grep mapdata - make - ''; + make -j $NIX_BUILD_CORES + ''; - installPhase = '' - # runHook preInstall - - mkdir -p $out/bin - cp -v viz1090 $out/bin - - # runHook postInstall - ''; -} + installPhase = '' + mkdir -p $out/bin + cp -v viz1090 $out/bin + ''; + }