mmdvm-flake/module.nix
2024-11-05 21:37:03 +01:00

51 lines
1.1 KiB
Nix

{ lib, config, pkgs, mmdvm_host, ... }:
with lib;
let
# Shorter name to access final settings a
# user of hello.nix module HAS ACTUALLY SET.
# cfg is a typical convention.
cfg = config.services.mmdvm_host;
in
{
options.services.mmdvm_host = {
enable = mkEnableOption "MMDVMHost service";
package = mkOption {
default = mmdvm_host.x86_64-linux.default;
type = types.package;
};
user = mkOption {
type = types.str;
default = "afg";
};
};
config = mkIf cfg.enable {
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = [
cfg.package
];
systemd.services.mmdvm_host = {
wantedBy = [ "multi-user.target" ];
wants = [ "network.target" ];
after = [ "network.target" ];
description = "MMDVMHost service";
serviceConfig = {
Type = "exec";
User = cfg.user;
Restart = "always";
RestartSec = "3s";
StartLimitIntervalSec = "0";
RuntimeDirectory = "MMDVMHost";
};
script = ''
exec ${cfg.package}/bin/MMDVMHost
'';
};
};
}