From f0a32ae9ae5d7235869ead8c5fa48f1cd26b7618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Fri, 19 Jan 2024 15:12:30 +0200 Subject: [PATCH] top-level modules: make work --- flake.nix | 4 +++- modules/e11sync/default.nix | 19 +++++++++++-------- pkgs.nix | 16 ++++++++-------- pkgs/e11sync-backend.nix | 4 ++-- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/flake.nix b/flake.nix index 15dd2ea..cfc3e08 100644 --- a/flake.nix +++ b/flake.nix @@ -125,6 +125,8 @@ self.nixosModules.e11sync ]; }; - nixosModules.e11sync = import ./modules/e11sync nixpkgs; + nixosModules.e11sync = import ./modules/e11sync { + inherit nixpkgs geoip2-tarball; + }; }; } diff --git a/modules/e11sync/default.nix b/modules/e11sync/default.nix index 79d954f..eb39f91 100644 --- a/modules/e11sync/default.nix +++ b/modules/e11sync/default.nix @@ -1,11 +1,14 @@ -nixpkgs: { +{ + nixpkgs, + geoip2-tarball, +}: { config, lib, - system, - geoip2-tarball, + pkgs, ... }: let - pkgs = import ../../pkgs.nix {inherit nixpkgs system geoip2-tarball;}; + inherit (pkgs.stdenv.hostPlatform) system; + pkgs1 = import ../../pkgs.nix {inherit nixpkgs system geoip2-tarball;}; in { options.e11sync = with lib.types; { enable = lib.mkEnableOption "Enable e11sync"; @@ -34,7 +37,7 @@ in { in lib.mkIf cfg.enable { environment.systemPackages = [ - pkgs.e11sync-backend + pkgs1.e11sync-backend ]; systemd.services = { @@ -59,7 +62,7 @@ in { StateDirectory = "e11sync-backend"; WorkingDirectory = "/var/lib/e11sync-backend"; KillSignal = "SIGQUIT"; - ExecStart = "${pkgs.e11sync-backend}/bin/e11sync-backend"; + ExecStart = "${pkgs1.e11sync-backend}/bin/e11sync-backend"; MemoryHigh = "1535M"; MemoryMax = "4096M"; @@ -71,7 +74,7 @@ in { ProtectControlGroups = true; } (lib.mkIf cfg.migrateOnStart { - ExecStartPre = "${pkgs.e11sync-backend}/bin/e11sync migrate"; + ExecStartPre = "${pkgs1.e11sync-backend}/bin/e11sync migrate"; }) (lib.mkIf (cfg.secretKeyPath != "unsafe") { LoadCredential = "secret_key:${cfg.secretKeyPath}"; @@ -81,6 +84,6 @@ in { }; services.caddy.virtualHosts."${cfg.vhost}".extraConfig = - builtins.readFile "${pkgs.e11sync-frontend}"; + builtins.readFile "${pkgs1.e11sync-frontend}"; }; } diff --git a/pkgs.nix b/pkgs.nix index 77e4dea..8ae540a 100644 --- a/pkgs.nix +++ b/pkgs.nix @@ -3,9 +3,7 @@ system, geoip2-tarball, }: let - inherit (import nixpkgs {inherit system;}) callPackage; -in - import nixpkgs { + pkgs = import nixpkgs { inherit system; overlays = [ (_: super: { @@ -14,12 +12,14 @@ in django = python-super.django_5; }; }; - geoip-mmdb = callPackage ./pkgs/geoip-mmdb.nix { + geoip-mmdb = pkgs.callPackage ./pkgs/geoip-mmdb.nix { inherit geoip2-tarball; }; - e11sync-static = callPackage ./pkgs/e11sync-static.nix {}; - e11sync-frontend = callPackage ./pkgs/e11sync-frontend.nix {}; - e11sync-backend = callPackage ./pkgs/e11sync-backend.nix {}; + e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {}; + e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix {}; + e11sync-backend = pkgs.callPackage ./pkgs/e11sync-backend.nix {}; }) ]; - } + }; +in + pkgs diff --git a/pkgs/e11sync-backend.nix b/pkgs/e11sync-backend.nix index e244713..4ba03a1 100644 --- a/pkgs/e11sync-backend.nix +++ b/pkgs/e11sync-backend.nix @@ -10,7 +10,7 @@ backendPort ? 8002, databasePath ? null, geoip-mmdb, - e11sync-static-manifest, + e11sync-static, }: let uwsgi-python = uwsgi.override {plugins = ["python3"];}; pythonEnv = @@ -50,7 +50,7 @@ in ${lib.optionalString (databasePath != null) '' --set E11SYNC_DATABASE_PATH "${databasePath}" \ ''} \ - --set E11SYNC_STATIC_ROOT "${e11sync-static-manifest}" \ + --set E11SYNC_STATIC_ROOT "${e11sync-static.passthru.manifest}" \ --set E11SYNC_COMPRESS_OFFLINE 1 \ --set E11SYNC_DEBUG "" \ --set GEOIP_PATH "${geoip-mmdb}" \