Skip to content

Commit

Permalink
Enhance flake systemd integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dacr committed Nov 22, 2024
1 parent a0fde57 commit ec83265
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,38 @@
# simple nixos services integration
nixosModules.default = { config, pkgs, lib, ... }: {
options = {
services.web-echo.enable = lib.mkEnableOption "web-echo";
services.web-echo = {
enable = lib.mkEnableOption "web-echo";
user = lib.mkOption {
type = lib.types.str;
description = "User name that will run the web echo service";
};
prefix = lib.mkOption {
type = lib.types.str;
description = "Service web echo url prefix";
default = "";
};
port = lib.mkOption {
type = lib.types.int;
description = "Service web echo listing port";
default = 8080;
};
};
};
config = lib.mkIf config.services.web-echo.enable {
systemd.services.web-echo = {
description = "Record your json data coming from websockets or webhooks";
unitConfig = {
Type = "simple";
User = "web-echo";
};
environment = {
WEB_ECHO_LISTEN_PORT = config.services.web-echo.port;
WEB_ECHO_PREFIX = config.services.web-echo.prefix;
};
serviceConfig = {
ExecStart = "${self.packages.${pkgs.system}.default}/bin/nix-web-echo";
User = config.services.web-echo-user;
Restart = "on-failure";
};
wantedBy = [ "multi-user.target" ];
};
Expand Down

0 comments on commit ec83265

Please sign in to comment.