[flake] the module now actually starts the prod server

This commit is contained in:
2026-07-30 18:34:21 +02:00
parent a8e80ed19d
commit 04a76f91fe
2 changed files with 18 additions and 9 deletions

View File

@@ -123,6 +123,7 @@
''); '');
}; };
}); });
nixosModules = { gatekeeper = import ./module.nix; }; nixosModules.gatekeeper = { config, pkgs, lib, ... }@args:
import ./module.nix (args // { self = self; system = pkgs.system; });
}; };
} }

View File

@@ -8,33 +8,41 @@ in
enable = lib.mkEnableOption "Enable the gatekeeper api service."; enable = lib.mkEnableOption "Enable the gatekeeper api service.";
dotenv = lib.mkOption { dotenv = lib.mkOption {
type = lib.types.path; type = lib.types.path;
default = null;
description = "The path to a .env file with the keys"; description = "The path to a .env file with the keys";
}; };
db = { db = lib.mkOption {
type = lib.types.path; type = lib.types.path;
default = null;
description = "Where to save the database."; description = "Where to save the database.";
}; };
}; };
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.extraGroups.gatekeeper = {}; users.groups.gatekeeper = {};
users.extraUsers.gatekeeper = { users.users.gatekeeper = {
description = "gatekeeper user"; description = "gatekeeper user";
group = "gatekeeper"; group = "gatekeeper";
isSystemUser = true; isSystemUser = true;
}; };
environment.systemPackages = [self.packages.${system}.default]; services.pcscd = {
enable = true;
plugins = [ pkgs.acsccid ];
};
networking.firewall.allowedTCPPorts = [ 8000 ];
systemd.services.gatekeeper = { systemd.services.gatekeeper = {
description = "Runs the gatekeeper api";
script = '' script = ''
export LD_LIBRARY_PATH="${lib.getLib pkgs.legacyPackages.${system}.pcsclite}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" export LD_LIBRARY_PATH="${lib.getLib pkgs.pcsclite}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec ${self.packages.${system}.default}/bin/fastapi run ${self}/app/main.py exec ${self.packages.${system}.default}/bin/uvicorn --host 0.0.0.0 --port 8000 --app-dir ${self} app.main:app
''; '';
after = [ "network.target" ];
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
serviceConfig = { serviceConfig = {
User = "gatekeeper"; User = "gatekeeper";
Restart = "on-failure"; Restart = "on-failure";
RestartSec = "20";
StateDirectory = "gatekeeper";
WorkingDirectory = "/var/lib/gatekeeper";
}; };
}; };
}; };