cleanup
This commit is contained in:
@@ -1,54 +1,39 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
config,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.${namespace}) mkOpt;
|
||||
name = "netbootxyz";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
netbootxyzConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "netbootxyz";
|
||||
options = {
|
||||
assetPort = mkOpt types.port 4001 "NGINX server for hosting assets.";
|
||||
|
||||
tftpPort = mkOpt types.port 69 "HTTPS port for netbootxyz";
|
||||
};
|
||||
moduleConfig = {
|
||||
# Open firewall for netbootxyz if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [
|
||||
cfg.assetPort
|
||||
cfg.tftpPort
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
cfg.assetPort
|
||||
cfg.tftpPort
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers = {
|
||||
containers.netbootxyz = {
|
||||
autoStart = true;
|
||||
image = "ghcr.io/netbootxyz/netbootxyz:latest";
|
||||
ports = [
|
||||
"${toString cfg.port}:3000"
|
||||
"${toString cfg.assetPort}:80"
|
||||
"${toString cfg.tftpPort}:69"
|
||||
];
|
||||
volumes = [
|
||||
"${cfg.configDir}/netbootxyz:/config"
|
||||
"${cfg.dataDir}/isos:/assets"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
inherit (lib.${namespace}) mkOpt mkContainerService;
|
||||
cfg = config.${namespace}.services.netbootxyz;
|
||||
in
|
||||
{
|
||||
imports = [ netbootxyzConfig ];
|
||||
imports = [
|
||||
(mkContainerService {
|
||||
inherit config;
|
||||
name = "netbootxyz";
|
||||
image = "ghcr.io/netbootxyz/netbootxyz:latest";
|
||||
internalPort = 3000;
|
||||
options = {
|
||||
assetPort = mkOpt lib.types.port 4001 "NGINX port for hosting assets";
|
||||
tftpPort = mkOpt lib.types.port 69 "TFTP port";
|
||||
};
|
||||
volumes = [
|
||||
"${cfg.configDir}/netbootxyz:/config"
|
||||
"${cfg.dataDir}/isos:/assets"
|
||||
];
|
||||
extraConfig = {
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.assetPort cfg.tftpPort ];
|
||||
allowedUDPPorts = [ cfg.assetPort cfg.tftpPort ];
|
||||
};
|
||||
virtualisation.oci-containers.containers.netbootxyz.ports = lib.mkForce [
|
||||
"${toString cfg.port}:3000"
|
||||
"${toString cfg.assetPort}:80"
|
||||
"${toString cfg.tftpPort}:69"
|
||||
];
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user