1

vm bulds, but with django4

This commit is contained in:
Motiejus Jakštys 2024-01-17 15:02:59 +02:00
parent 8bc0c13565
commit 66d8a424a2
2 changed files with 22 additions and 9 deletions

View File

@ -45,6 +45,12 @@
django = python-super.django_5; django = python-super.django_5;
}; };
}; };
geoip-mmdb = pkgs.callPackage ./pkgs/geoip-mmdb.nix {
inherit geoip2-tarball;
};
e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {};
e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix {};
e11sync-backend = pkgs.callPackage ./pkgs/e11sync-backend.nix {};
}) })
]; ];
}; };
@ -153,8 +159,9 @@
modules = [ modules = [
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
./vm.nix ./vm.nix
self.nixosModules.x86_64-linux.e11sync self.nixosModules.e11sync
]; ];
}; };
nixosModules.e11sync = import ./modules/e11sync geoip2-tarball;
}; };
} }

View File

@ -1,9 +1,7 @@
{ geoip2-tarball: {
e11sync-backend,
e11sync-frontend,
}: {
config, config,
lib, lib,
pkgs,
... ...
}: { }: {
options.e11sync = with lib.types; { options.e11sync = with lib.types; {
@ -30,13 +28,21 @@
config = let config = let
cfg = config.e11sync; cfg = config.e11sync;
pkg-backend = e11sync-backend.override { geoip-mmdb = pkgs.callPackage ../../pkgs/geoip-mmdb.nix {
inherit geoip2-tarball;
};
e11sync-static = pkgs.callPackage ../../pkgs/e11sync-static.nix {};
e11sync-frontend = pkgs.callPackage ../../pkgs/e11sync-frontend.nix {
inherit e11sync-static;
};
e11sync-backend = pkgs.callPackage ../../pkgs/e11sync-backend.nix {
inherit e11sync-static geoip-mmdb;
inherit (cfg) backendPort databasePath; inherit (cfg) backendPort databasePath;
}; };
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
environment.systemPackages = [ environment.systemPackages = [
pkg-backend e11sync-backend
]; ];
systemd.services = { systemd.services = {
@ -61,7 +67,7 @@
StateDirectory = "e11sync-backend"; StateDirectory = "e11sync-backend";
WorkingDirectory = "/var/lib/e11sync-backend"; WorkingDirectory = "/var/lib/e11sync-backend";
KillSignal = "SIGQUIT"; KillSignal = "SIGQUIT";
ExecStart = "${pkg-backend}/bin/e11sync-backend"; ExecStart = "${e11sync-backend}/bin/e11sync-backend";
MemoryHigh = "1535M"; MemoryHigh = "1535M";
MemoryMax = "4096M"; MemoryMax = "4096M";
@ -73,7 +79,7 @@
ProtectControlGroups = true; ProtectControlGroups = true;
} }
(lib.mkIf cfg.migrateOnStart { (lib.mkIf cfg.migrateOnStart {
ExecStartPre = "${pkg-backend}/bin/e11sync migrate"; ExecStartPre = "${e11sync-backend}/bin/e11sync migrate";
}) })
(lib.mkIf (cfg.secretKeyPath != "unsafe") { (lib.mkIf (cfg.secretKeyPath != "unsafe") {
LoadCredential = "secret_key:${cfg.secretKeyPath}"; LoadCredential = "secret_key:${cfg.secretKeyPath}";