113 lines
3.3 KiB
Nix
113 lines
3.3 KiB
Nix
{
|
|
nixConfig = {
|
|
trusted-substituters = "https://cache.nixos.org/";
|
|
trusted-public-keys = "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=";
|
|
extra-experimental-features = "nix-command flakes";
|
|
};
|
|
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";
|
|
flake = false;
|
|
};
|
|
|
|
flake-compat.url = "github:nix-community/flake-compat";
|
|
gitignore.url = "github:hercules-ci/gitignore.nix";
|
|
gitignore.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
pre-commit-hooks = {
|
|
url = "github:cachix/pre-commit-hooks.nix";
|
|
inputs = {
|
|
nixpkgs.follows = "nixpkgs";
|
|
nixpkgs-stable.follows = "nixpkgs";
|
|
flake-compat.follows = "flake-compat";
|
|
flake-utils.follows = "flake-utils";
|
|
gitignore.follows = "gitignore";
|
|
};
|
|
};
|
|
};
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
pre-commit-hooks,
|
|
geoip2-asn,
|
|
geoip2-city,
|
|
geoip2-country,
|
|
...
|
|
} @ 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;
|
|
};
|
|
|
|
e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {};
|
|
|
|
e11sync = pkgs.callPackage ./pkgs/e11sync.nix {inherit geoip-archive;};
|
|
in {
|
|
packages = {
|
|
inherit geoip-archive e11sync-static e11sync;
|
|
};
|
|
|
|
checks = {
|
|
e11sync-unit = e11sync.passthru.tests.unit;
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
src = ./.;
|
|
hooks = {
|
|
alejandra.enable = true;
|
|
deadnix.enable = true;
|
|
statix.enable = true;
|
|
};
|
|
};
|
|
format = pkgs.runCommand "check-format" {} ''
|
|
${pkgs.python3Packages.flake8}/bin/flake8 \
|
|
--exclude ${./.}/app/signup/migrations/ ${./.}/app
|
|
mkdir -p $out
|
|
'';
|
|
};
|
|
|
|
apps.e11sync-gunicorn = {
|
|
type = "app";
|
|
name = "e11sync-gunicorn";
|
|
program = toString (pkgs.writeShellScript "wrapper" ''
|
|
export E11SYNC_DATABASE_PATH=$PWD/db.sqlite3
|
|
exec ${e11sync}/bin/e11sync-gunicorn
|
|
'');
|
|
};
|
|
|
|
devShells.default = pkgs.mkShellNoCC {
|
|
packages = with pkgs; [
|
|
python3Packages.django_5
|
|
python3Packages.django-compressor
|
|
python3Packages.geoip2
|
|
libmaxminddb
|
|
dart-sass
|
|
|
|
python3Packages.django-debug-toolbar
|
|
python3Packages.flake8
|
|
|
|
# TODO: vim integration via EXITINT?
|
|
# autopep8 --in-place --recursive .
|
|
python3Packages.autopep8
|
|
];
|
|
GEOIP_PATH = "${geoip-archive}";
|
|
E11SYNC_DEBUG = "1";
|
|
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
|
inherit (inputs.self.checks.${system}.pre-commit-check) shellHook;
|
|
};
|
|
|
|
formatter = pkgs.alejandra;
|
|
});
|
|
}
|