geoip: compress the archive
less inputs, less downloading.
This commit is contained in:
parent
85b75daba5
commit
290838e6e7
47
flake.lock
47
flake.lock
@ -20,11 +20,11 @@
|
|||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1701680307,
|
"lastModified": 1705306982,
|
||||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
"narHash": "sha256-ZOnxPL+HBfF/qzYFCcuU1fclOejFIgcaI7UXYAEhK2k=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
"rev": "c8eb208c255400b59b60ad5de17e9f8f7ef8ae30",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -33,40 +33,17 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"geoip2-asn": {
|
"geoip2-tarball": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"narHash": "sha256-yGxCynYbOdA65wtcSO+Sjpo5eFOd1gdfRBuSWnbmPqs=",
|
"lastModified": 1705308463,
|
||||||
"type": "file",
|
"narHash": "sha256-Q+t6LnGy8R6QLugw25iC0WdVPU2C3eqZPlbvVQ9EpwE=",
|
||||||
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-ASN.mmdb"
|
"type": "tarball",
|
||||||
|
"url": "https://dl.jakstys.lt/_/2024.01.13.tar.zst"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "file",
|
"type": "tarball",
|
||||||
"url": "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-ASN.mmdb"
|
"url": "https://dl.jakstys.lt/_/2024.01.13.tar.zst"
|
||||||
}
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"gitignore": {
|
"gitignore": {
|
||||||
@ -141,9 +118,7 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"geoip2-asn": "geoip2-asn",
|
"geoip2-tarball": "geoip2-tarball",
|
||||||
"geoip2-city": "geoip2-city",
|
|
||||||
"geoip2-country": "geoip2-country",
|
|
||||||
"gitignore": "gitignore",
|
"gitignore": "gitignore",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"pre-commit-hooks": "pre-commit-hooks"
|
"pre-commit-hooks": "pre-commit-hooks"
|
||||||
|
26
flake.nix
26
flake.nix
@ -7,16 +7,8 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
geoip2-asn = {
|
geoip2-tarball = {
|
||||||
url = "https://dl.jakstys.lt/_/2024.01.10/GeoLite2-ASN.mmdb";
|
url = "https://dl.jakstys.lt/_/2024.01.13.tar.zst";
|
||||||
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";
|
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,24 +32,22 @@
|
|||||||
nixpkgs,
|
nixpkgs,
|
||||||
flake-utils,
|
flake-utils,
|
||||||
pre-commit-hooks,
|
pre-commit-hooks,
|
||||||
geoip2-asn,
|
geoip2-tarball,
|
||||||
geoip2-city,
|
|
||||||
geoip2-country,
|
|
||||||
...
|
...
|
||||||
} @ inputs:
|
} @ inputs:
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
pkgs = import nixpkgs {inherit system;};
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
|
||||||
geoip-archive = pkgs.callPackage ./pkgs/geoip-archive.nix {
|
geoip-mmdb = pkgs.callPackage ./pkgs/geoip-mmdb.nix {
|
||||||
inherit geoip2-asn geoip2-city geoip2-country;
|
inherit geoip2-tarball;
|
||||||
};
|
};
|
||||||
|
|
||||||
e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {};
|
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 {
|
in {
|
||||||
packages = {
|
packages = {
|
||||||
inherit geoip-archive;
|
inherit geoip-mmdb;
|
||||||
inherit e11sync-static;
|
inherit e11sync-static;
|
||||||
inherit e11sync;
|
inherit e11sync;
|
||||||
};
|
};
|
||||||
@ -116,7 +106,7 @@
|
|||||||
# autopep8 --in-place --recursive .
|
# autopep8 --in-place --recursive .
|
||||||
python3Packages.autopep8
|
python3Packages.autopep8
|
||||||
];
|
];
|
||||||
GEOIP_PATH = "${geoip-archive}";
|
GEOIP_PATH = "${geoip-mmdb}";
|
||||||
E11SYNC_DEBUG = "1";
|
E11SYNC_DEBUG = "1";
|
||||||
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
||||||
inherit (inputs.self.checks.${system}.pre-commit-check) shellHook;
|
inherit (inputs.self.checks.${system}.pre-commit-check) shellHook;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
dart-sass,
|
dart-sass,
|
||||||
gunicornPort ? 8001,
|
gunicornPort ? 8001,
|
||||||
database-path ? null,
|
database-path ? null,
|
||||||
geoip-archive,
|
geoip-mmdb,
|
||||||
}:
|
}:
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "e11sync";
|
name = "e11sync";
|
||||||
@ -32,12 +32,12 @@ stdenv.mkDerivation {
|
|||||||
''} \
|
''} \
|
||||||
--set E11SYNC_DEBUG "" \
|
--set E11SYNC_DEBUG "" \
|
||||||
--set E11SYNC_COMPRESS_OFFLINE 1 \
|
--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 --bind=127.0.0.1:\$E11SYNC_HTTP_PORT \
|
||||||
--add-flags e11sync.wsgi
|
--add-flags e11sync.wsgi
|
||||||
|
|
||||||
makeWrapper $out/app/manage.py $out/bin/e11sync \
|
makeWrapper $out/app/manage.py $out/bin/e11sync \
|
||||||
--set GEOIP_PATH "${geoip-archive}"
|
--set GEOIP_PATH "${geoip-mmdb}"
|
||||||
'';
|
'';
|
||||||
passthru.tests.unit =
|
passthru.tests.unit =
|
||||||
runCommand "e11sync-test" {
|
runCommand "e11sync-test" {
|
||||||
@ -51,7 +51,7 @@ stdenv.mkDerivation {
|
|||||||
} ''
|
} ''
|
||||||
unpackPhase
|
unpackPhase
|
||||||
patchShebangs --build app/manage.py
|
patchShebangs --build app/manage.py
|
||||||
export GEOIP_PATH="${geoip-archive}"
|
export GEOIP_PATH="${geoip-mmdb}"
|
||||||
app/manage.py test app
|
app/manage.py test app
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
'';
|
'';
|
||||||
|
@ -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
12
pkgs/geoip-mmdb.nix
Normal 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/
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user