summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-03 04:27:32 +0200
committerRory& <root@rory.gay>2025-06-03 04:27:32 +0200
commitde650a5aad4060bc3984f7d6c184cd23fd3d7e75 (patch)
treea2f9e96a1c43b0bca4af3b05c04380679cb07a9d /flake.nix
parentSimple nixOS module (diff)
downloadnodejs-final-assignment-de650a5aad4060bc3984f7d6c184cd23fd3d7e75.tar.xz
Fix nix package, implement module
Diffstat (limited to '')
-rw-r--r--flake.nix31
1 files changed, 29 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix

index bbd4476..5b2f8fc 100644 --- a/flake.nix +++ b/flake.nix
@@ -87,7 +87,7 @@ } )) // { nixosModules.default = { config, lib, ...}: { - options.safensound = { + options.services.safensound = { enable = lib.mkEnableOption "Enable SafeNSound service"; package = lib.mkOption { type = lib.types.package; @@ -105,7 +105,7 @@ default = "mongodb-pass"; description = "Path to the database credentials file."; }; - JwtSecretPath = lib.mkOption { + jwtSecretPath = lib.mkOption { type = lib.types.path; default = "."; description = "Path to the JWT secret directory."; @@ -113,6 +113,33 @@ logQueries = lib.mkEnableOption "Log queries"; logAuth = lib.mkEnableOption "Log authentication"; }; + + config = lib.mkIf (config.safensound.enable) ( + let + cfg = config.services.safensound; + in + { + systemd.services.safensound = { + description = "SafeNSound Service"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" "mongodb.service" ]; + requires = [ "mongodb.service" ]; + environment = { + PORT = cfg.port; + LOG_REQUESTS = cfg.logRequests; + DATABASE_SECRET_PATH = cfg.dbCredentialsPath; + JWT_SECRET_PATH = cfg.jwtSEcretPath; + LOG_QUERIES = cfg.logQueries; + LOG_AUTH = cfg.logAuth; + }; + serviceConfig = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/start"; + Restart = "on-failure"; + DynamicUser = true; + }; + }; + }); }; }; } \ No newline at end of file