mmdvm-flake/module.nix

51 lines
1.1 KiB
Nix
Raw Normal View History

2024-11-05 21:30:44 +01:00
{ 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 = {
2024-11-05 21:37:03 +01:00
enable = mkEnableOption "MMDVMHost service";
2024-11-05 21:30:44 +01:00
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" ];
2024-11-05 21:37:03 +01:00
description = "MMDVMHost service";
2024-11-05 21:30:44 +01:00
serviceConfig = {
Type = "exec";
User = cfg.user;
Restart = "always";
RestartSec = "3s";
StartLimitIntervalSec = "0";
2024-11-05 21:37:03 +01:00
RuntimeDirectory = "MMDVMHost";
2024-11-05 21:30:44 +01:00
};
script = ''
2024-11-05 21:37:03 +01:00
exec ${cfg.package}/bin/MMDVMHost
2024-11-05 21:30:44 +01:00
'';
};
};
}