Fix nix package, implement module
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
|