merge
This commit is contained in:
57
modules/nixos/netbootxyz/default.nix
Normal file
57
modules/nixos/netbootxyz/default.nix
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
namespace,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.netbootxyz;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Open firewall for netbootxyz if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [
|
||||
cfg.httpPort
|
||||
cfg.httpsPort
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
cfg.httpPort
|
||||
cfg.httpsPort
|
||||
];
|
||||
};
|
||||
|
||||
# Create data directory
|
||||
systemd.tmpfiles.rules = [
|
||||
"d ${cfg.dataDir} 0755 root root -"
|
||||
];
|
||||
|
||||
# Configure netbootxyz as a container service
|
||||
virtualisation.oci-containers = {
|
||||
backend = "podman";
|
||||
containers.netbootxyz = {
|
||||
image = "ghcr.io/netbootxyz/netbootxyz:latest";
|
||||
ports = [
|
||||
"${toString cfg.httpPort}:3000"
|
||||
"${toString cfg.httpsPort}:3001"
|
||||
];
|
||||
volumes = [
|
||||
"${cfg.dataDir}:/app/src/config"
|
||||
];
|
||||
environment = {
|
||||
MENU_VERSION = "2.0.76";
|
||||
PORT_RANGE = "30000:30010";
|
||||
};
|
||||
extraOptions = [
|
||||
"--restart=unless-stopped"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Enable podman for oci-containers
|
||||
virtualisation.podman.enable = true;
|
||||
};
|
||||
}
|
||||
31
modules/nixos/netbootxyz/options.nix
Normal file
31
modules/nixos/netbootxyz/options.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.netbootxyz = {
|
||||
enable = mkEnableOption "netbootxyz network boot service";
|
||||
|
||||
httpPort = mkOption {
|
||||
type = types.port;
|
||||
default = 4000;
|
||||
description = "HTTP port for netbootxyz";
|
||||
};
|
||||
|
||||
httpsPort = mkOption {
|
||||
type = types.port;
|
||||
default = 4080;
|
||||
description = "HTTPS port for netbootxyz";
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to open firewall for netbootxyz";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/netbootxyz";
|
||||
description = "Data directory for netbootxyz";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user