nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

commit 7e5cd4632b9b4e8c6de42e257a25456d737c6d94
parent 3878275ff3afab66530f17f5b99ec6f89b65b148
Author: Nikolay Korotkiy <sikmir@disroot.org>
Date:   Tue,  4 Jun 2024 23:17:55 +0400

Add tracks_storage_server module

Diffstat:
Mmodules/nixos/default.nix | 5++++-
Amodules/nixos/services/tracks_storage_server.nix | 34++++++++++++++++++++++++++++++++++
Mpkgs/default.nix | 2+-
Mpkgs/nakarte/tracks_storage_server/default.nix | 57+++++++++++++++++++++++++++++----------------------------
4 files changed, 68 insertions(+), 30 deletions(-)

diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix @@ -1 +1,4 @@ -{ mbtileserver = ./services/mbtileserver.nix; } +{ + mbtileserver = ./services/mbtileserver.nix; + tracks_storage_server = ./services/tracks_storage_server.nix; +} diff --git a/modules/nixos/services/tracks_storage_server.nix b/modules/nixos/services/tracks_storage_server.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + pkgs, + ... +}: + +with lib; + +let + cfg = config.services.tracks_storage_server; +in +{ + options.services.tracks_storage_server = { + enable = mkEnableOption "tracks_storage_server"; + package = mkPackageOption pkgs "tracks_storage_server" { }; + }; + + config = mkIf cfg.enable { + services.uwsgi.enable = true; + services.uwsgi.plugins = [ "python3" ]; + services.uwsgi.instance = { + type = "emperor"; + vassals.tracks = { + type = "normal"; + master = true; + workers = 2; + socket = "127.0.0.1:8181"; + module = "server:application"; + pythonPackages = self: [ cfg.package ]; + }; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix @@ -441,7 +441,7 @@ lib.makeScope newScope ( thinplatespline = callPackage ./nakarte/thinplatespline { python3Packages = pkgs.python39Packages; }; - tracks_storage_server = callPackage ./nakarte/tracks_storage_server { }; + tracks_storage_server = pkgs.python3Packages.callPackage ./nakarte/tracks_storage_server { }; ### OSM diff --git a/pkgs/nakarte/tracks_storage_server/default.nix b/pkgs/nakarte/tracks_storage_server/default.nix @@ -1,14 +1,29 @@ { lib, - stdenv, + buildPythonPackage, fetchFromGitHub, - python3Packages, + writeText, + msgpack, + protobuf, + psycopg2, }: -python3Packages.buildPythonApplication rec { +let + setupPy = writeText "setup.py" '' + from setuptools import setup + setup( + name='tracks_storage_server', + version='1.0', + install_requires=['msgpack', 'protobuf', 'psycopg2'], + py_modules=['server', 'nktk_raw_pb2', 'config'], + data_files=[('bin', ['init.sql'])], + scripts=['init_db.py'], + ) + ''; +in +buildPythonPackage rec { pname = "tracks_storage_server"; version = "2024-04-27"; - format = "other"; src = fetchFromGitHub { owner = "wladich"; @@ -17,32 +32,18 @@ python3Packages.buildPythonApplication rec { hash = "sha256-fN7OG52t2pHxFlCxhnMkVMpctsuwBQyuXMO9CD9eWLg="; }; - dontUseSetuptoolsBuild = true; - dontUseSetuptoolsCheck = true; + postPatch = '' + cp ${setupPy} ${setupPy.name} + substitute config.py.example config.py --replace-fail "'password" "#'password" + ''; - installPhase = - let - pythonEnv = python3Packages.python.withPackages ( - p: with p; [ - msgpack - protobuf - psycopg2 - ] - ); - in - '' - site_packages=$out/lib/${python3Packages.python.libPrefix}/site-packages - mkdir -p $site_packages - cp *.py *.sql $site_packages + propagatedBuildInputs = [ + msgpack + protobuf + psycopg2 + ]; - substitute config.py.example $site_packages/config.py \ - --replace-fail "'password" "#'password" - - makeWrapper ${pythonEnv.interpreter} $out/bin/tracks_storage_server \ - --add-flags "$site_packages/server.py" - makeWrapper ${pythonEnv.interpreter} $out/bin/init_db \ - --add-flags "$site_packages/init_db.py" - ''; + pythonImportsCheck = [ "server" ]; meta = { description = "Tracks storage server";