1
Fork 0

geoip: compress the archive

less inputs, less downloading.
This commit is contained in:
Motiejus Jakštys 2024-01-15 10:52:46 +02:00
parent 85b75daba5
commit 290838e6e7
5 changed files with 35 additions and 75 deletions

View File

@ -20,11 +20,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"lastModified": 1705306982,
"narHash": "sha256-ZOnxPL+HBfF/qzYFCcuU1fclOejFIgcaI7UXYAEhK2k=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"rev": "c8eb208c255400b59b60ad5de17e9f8f7ef8ae30",
"type": "github"
},
"original": {
@ -33,40 +33,17 @@
"type": "github"
}
},
"geoip2-asn": {
"geoip2-tarball": {
"flake": false,
"locked": {
"narHash": "sha256-yGxCynYbOdA65wtcSO+Sjpo5eFOd1gdfRBuSWnbmPqs=",
"type": "file",
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-ASN.mmdb"
"lastModified": 1705308463,
"narHash": "sha256-Q+t6LnGy8R6QLugw25iC0WdVPU2C3eqZPlbvVQ9EpwE=",
"type": "tarball",
"url": "https://dl.jakstys.lt/_/2024.01.13.tar.zst"
},
"original": {
"type": "file",
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-ASN.mmdb"
}
},
"geoip2-city": {
"flake": false,
"locked": {
"narHash": "sha256-M42YId3Kml/ks4z2HVJMsZ25GGQ6ISEBaz5du4tHGyc=",
"type": "file",
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-City.mmdb"
},
"original": {
"type": "file",
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-City.mmdb"
}
},
"geoip2-country": {
"flake": false,
"locked": {
"narHash": "sha256-5lecpKFEhhJuVtPSMpPz0nR8WHUF1XbJkN+h4K9VTSQ=",
"type": "file",
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-Country.mmdb"
},
"original": {
"type": "file",
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-Country.mmdb"
"type": "tarball",
"url": "https://dl.jakstys.lt/_/2024.01.13.tar.zst"
}
},
"gitignore": {
@ -141,9 +118,7 @@
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"geoip2-asn": "geoip2-asn",
"geoip2-city": "geoip2-city",
"geoip2-country": "geoip2-country",
"geoip2-tarball": "geoip2-tarball",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"

View File

@ -7,16 +7,8 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
geoip2-asn = {
url = "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-ASN.mmdb";
flake = false;
};
geoip2-city = {
url = "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-City.mmdb";
flake = false;
};
geoip2-country = {
url = "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-Country.mmdb";
geoip2-tarball = {
url = "https://dl.jakstys.lt/_/2024.01.13.tar.zst";
flake = false;
};
@ -40,24 +32,22 @@
nixpkgs,
flake-utils,
pre-commit-hooks,
geoip2-asn,
geoip2-city,
geoip2-country,
geoip2-tarball,
...
} @ inputs:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
geoip-archive = pkgs.callPackage ./pkgs/geoip-archive.nix {
inherit geoip2-asn geoip2-city geoip2-country;
geoip-mmdb = pkgs.callPackage ./pkgs/geoip-mmdb.nix {
inherit geoip2-tarball;
};
e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {};
e11sync = pkgs.callPackage ./pkgs/e11sync.nix {inherit geoip-archive;};
e11sync = pkgs.callPackage ./pkgs/e11sync.nix {inherit geoip-mmdb;};
in {
packages = {
inherit geoip-archive;
inherit geoip-mmdb;
inherit e11sync-static;
inherit e11sync;
};
@ -116,7 +106,7 @@
# autopep8 --in-place --recursive .
python3Packages.autopep8
];
GEOIP_PATH = "${geoip-archive}";
GEOIP_PATH = "${geoip-mmdb}";
E11SYNC_DEBUG = "1";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
inherit (inputs.self.checks.${system}.pre-commit-check) shellHook;

View File

@ -8,7 +8,7 @@
dart-sass,
gunicornPort ? 8001,
database-path ? null,
geoip-archive,
geoip-mmdb,
}:
stdenv.mkDerivation {
name = "e11sync";
@ -32,12 +32,12 @@ stdenv.mkDerivation {
''} \
--set E11SYNC_DEBUG "" \
--set E11SYNC_COMPRESS_OFFLINE 1 \
--set GEOIP_PATH "${geoip-archive}" \
--set GEOIP_PATH "${geoip-mmdb}" \
--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}"
--set GEOIP_PATH "${geoip-mmdb}"
'';
passthru.tests.unit =
runCommand "e11sync-test" {
@ -51,7 +51,7 @@ stdenv.mkDerivation {
} ''
unpackPhase
patchShebangs --build app/manage.py
export GEOIP_PATH="${geoip-archive}"
export GEOIP_PATH="${geoip-mmdb}"
app/manage.py test app
mkdir -p $out
'';

View File

@ -1,17 +0,0 @@
{
stdenv,
geoip2-asn,
geoip2-city,
geoip2-country,
}:
stdenv.mkDerivation {
name = "geoip-archive";
srcs = [geoip2-asn geoip2-city geoip2-country];
dontUnpack = true;
installPhase = ''
mkdir -p $out
cp ${geoip2-asn} $out/GeoLite2-ASN.mmdb
cp ${geoip2-city} $out/GeoLite2-City.mmdb
cp ${geoip2-country} $out/GeoLite2-Country.mmdb
'';
}

12
pkgs/geoip-mmdb.nix Normal file
View File

@ -0,0 +1,12 @@
{
stdenv,
geoip2-tarball,
}:
stdenv.mkDerivation {
name = "geoip-mmdb";
srcs = [geoip2-tarball];
installPhase = ''
mkdir -p $out
cp GeoLite2-ASN.mmdb GeoLite2-City.mmdb GeoLite2-Country.mmdb $out/
'';
}