mkModule various
This commit is contained in:
@@ -7,57 +7,57 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.glances;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
name = "glances";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Open firewall for glances if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
allowedUDPPorts = [ cfg.port ];
|
||||
};
|
||||
|
||||
# Install glances package
|
||||
environment.systemPackages = with pkgs; [
|
||||
glances
|
||||
];
|
||||
|
||||
# Configure systemd service for glances
|
||||
systemd.services.glances-server = {
|
||||
description = "Glances system monitoring web server";
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
path = with pkgs; [
|
||||
bash
|
||||
glancesConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "Glances system monitoring web server";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
# Install glances package
|
||||
environment.systemPackages = with pkgs; [
|
||||
glances
|
||||
];
|
||||
|
||||
script = ''
|
||||
glances -w --bind ${cfg.bindAddress} --port ${toString cfg.port}
|
||||
'';
|
||||
# Configure systemd service for glances
|
||||
systemd.services.glances-server = {
|
||||
description = "Glances system monitoring web server";
|
||||
enable = true;
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "glances";
|
||||
Group = "glances";
|
||||
Restart = "always";
|
||||
RestartSec = "5";
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
path = with pkgs; [
|
||||
bash
|
||||
glances
|
||||
];
|
||||
|
||||
script = ''
|
||||
glances -w --bind ${cfg.listenAddress} --port ${toString cfg.port}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "glances";
|
||||
Group = "glances";
|
||||
Restart = "always";
|
||||
RestartSec = "5";
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Create glances user and group
|
||||
users.users.glances = {
|
||||
isSystemUser = true;
|
||||
group = "glances";
|
||||
description = "Glances monitoring user";
|
||||
};
|
||||
# Create glances user and group
|
||||
users.users.glances = {
|
||||
isSystemUser = true;
|
||||
group = "glances";
|
||||
description = "Glances monitoring user";
|
||||
};
|
||||
|
||||
users.groups.glances = { };
|
||||
users.groups.glances = { };
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ glancesConfig ];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user