commit 6499795df1910a6bfeb0f7bd798660e9c26e18a8 (tree)
parent 96181f507570db6bccda0e34b62eeac4882bcaca
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date: Sun, 14 Jan 2024 19:54:32 +0200
e11sync: move to it's own package
Diffstat:
| M | flake.nix | | | 45 | ++++++--------------------------------------- |
| A | pkgs/e11sync.nix | | | 57 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 63 insertions(+), 39 deletions(-)
diff --git a/flake.nix b/flake.nix
@@ -30,16 +30,14 @@
...
}:
flake-utils.lib.eachDefaultSystem (system: let
- gunicornPort = 8001;
-
pkgs = import nixpkgs {inherit system;};
appDeps = with pkgs.python3Packages; [django_5 django-compressor];
runtimeDeps = with pkgs; appDeps ++ [python3Packages.geoip2 libmaxminddb];
buildDeps = with pkgs; appDeps ++ [dart-sass];
- geoip = pkgs.stdenv.mkDerivation {
- name = "geoip";
+ geoip-archive = pkgs.stdenv.mkDerivation {
+ name = "geoip-archive";
srcs = [geoip2-asn geoip2-city geoip2-country];
dontUnpack = true;
installPhase = ''
@@ -68,39 +66,8 @@
'';
installPhase = ''mv static $out'';
};
- packages.e11sync = pkgs.stdenv.mkDerivation {
- name = "e11sync";
- propagatedBuildInputs = [runtimeDeps];
- nativeBuildInputs = [pkgs.makeWrapper];
- src = self;
- dontUnpack = true;
- buildPhase = ''
- mkdir -p $out;
- cp -r ${self}/app $out
- makeWrapper ${pkgs.python3Packages.gunicorn}/bin/gunicorn $out/bin/e11sync-gunicorn \
- --chdir $out/app \
- --set-default E11SYNC_HTTP_PORT ${toString gunicornPort} \
- --set E11SYNC_DEBUG "" \
- --set E11SYNC_COMPRESS_OFFLINE 1 \
- --set GEOIP_PATH "${geoip}" \
- --add-flags --bind=127.0.0.1:\$E11SYNC_HTTP_PORT \
- --add-flags e11sync.wsgi
-
- makeWrapper $out/app/manage.py $out/bin/e11sync \
- --set GEOIP_PATH "${geoip}"
- '';
- passthru.tests = {
- simple =
- pkgs.runCommand "e11sync-test" {
- src = self;
- buildInputs = runtimeDeps ++ buildDeps;
- } ''
- mkdir -p $out
- cd ${self}/app
- export GEOIP_PATH="${geoip}"
- ${pkgs.python3}/bin/python3 ./manage.py test
- '';
- };
+ packages.e11sync = pkgs.callPackage ./pkgs/e11sync.nix {
+ inherit self geoip-archive;
};
checks.e11sync = packages.e11sync.passthru.tests.simple;
@@ -113,13 +80,13 @@
export E11SYNC_DATABASE_PATH=$PWD/db.sqlite3
exec ${packages.e11sync}/bin/e11sync-gunicorn
'';
- in "${wrapper}";
+ in "${wrapper}";
};
devShells.default = pkgs.mkShellNoCC {
packages = [pkgs.python3Packages.django-debug-toolbar] ++ runtimeDeps ++ buildDeps;
- GEOIP_PATH = "${geoip}";
+ GEOIP_PATH = "${geoip-archive}";
E11SYNC_DEBUG = "1";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
};
diff --git a/pkgs/e11sync.nix b/pkgs/e11sync.nix
@@ -0,0 +1,57 @@
+{
+ self,
+ stdenv,
+ runCommand,
+ makeWrapper,
+ python3,
+ python3Packages,
+ libmaxminddb,
+ dart-sass,
+ gunicornPort ? 8001,
+ geoip-archive,
+}:
+stdenv.mkDerivation {
+ name = "e11sync";
+ propagatedBuildInputs = [
+ python3Packages.django_5
+ python3Packages.django-compressor
+ python3Packages.geoip2
+ libmaxminddb
+ ];
+ nativeBuildInputs = [makeWrapper];
+ src = self;
+ dontUnpack = true;
+ buildPhase = ''
+ mkdir -p $out;
+ cp -r ${self}/app $out
+ makeWrapper ${python3Packages.gunicorn}/bin/gunicorn $out/bin/e11sync-gunicorn \
+ --chdir $out/app \
+ --set-default E11SYNC_HTTP_PORT ${toString gunicornPort} \
+ --set E11SYNC_DEBUG "" \
+ --set E11SYNC_COMPRESS_OFFLINE 1 \
+ --set GEOIP_PATH "${geoip-archive}" \
+ --add-flags --bind=127.0.0.1:\$E11SYNC_HTTP_PORT \
+ --add-flags e11sync.wsgi
+
+ makeWrapper $out/app/manage.py $out/bin/e11sync \
+ --set GEOIP_PATH "${geoip-archive}"
+ '';
+ passthru.tests = {
+ simple =
+ runCommand "e11sync-test" {
+ src = self;
+ buildInputs = [
+ python3Packages.django_5
+ python3Packages.django-compressor
+ python3Packages.geoip2
+ libmaxminddb
+ dart-sass
+ ];
+ } ''
+ mkdir -p $out
+ cd ${self}/app
+ export GEOIP_PATH="${geoip-archive}"
+ ${python3}/bin/python3 ./manage.py test
+ '';
+ };
+}