server hotspot
This commit is contained in:
parent
e9a3594518
commit
4c0362efb7
7 changed files with 45 additions and 53 deletions
|
|
@ -13,7 +13,6 @@
|
|||
imports = [
|
||||
../common.nix
|
||||
./fs.nix
|
||||
./pxeboot.nix
|
||||
./vps-init.nix
|
||||
];
|
||||
networking = {
|
||||
|
|
@ -21,24 +20,22 @@
|
|||
dns = "dnsmasq";
|
||||
ensureProfiles = {
|
||||
environmentFiles = [ config.sops.secrets.wifi-env.path ];
|
||||
profiles.home-wifi = {
|
||||
connection = {
|
||||
id = "home-wifi";
|
||||
type = "wifi";
|
||||
profiles = {
|
||||
dhcp-ethernet.connection = {
|
||||
id = "dhcp-ethernet";
|
||||
type = "ethernet";
|
||||
};
|
||||
ipv4 = {
|
||||
gateway = "10.1.0.1";
|
||||
method = "manual";
|
||||
home-wifi = {
|
||||
connection = {
|
||||
id = "home-wifi";
|
||||
type = "wifi";
|
||||
};
|
||||
wifi-security = {
|
||||
key-mgmt = "sae";
|
||||
psk = "$BOGALE_PSK";
|
||||
};
|
||||
wifi.ssid = "bogale";
|
||||
};
|
||||
ipv6 = {
|
||||
gateway = "fc01::1";
|
||||
method = "manual";
|
||||
};
|
||||
wifi-security = {
|
||||
key-mgmt = "sae";
|
||||
psk = "$BOGALE_5_PSK";
|
||||
};
|
||||
wifi.ssid = "bogale_5";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
114
mods/pxeboot.nix
114
mods/pxeboot.nix
|
|
@ -1,114 +0,0 @@
|
|||
{ config, pkgs, ... }: {
|
||||
networking = {
|
||||
firewall = {
|
||||
allowedTCPPorts = [
|
||||
2049
|
||||
53
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
53
|
||||
547
|
||||
67
|
||||
69
|
||||
];
|
||||
};
|
||||
nat = {
|
||||
enable = true;
|
||||
enableIPv6 = true;
|
||||
internalInterfaces = [ "br0" ];
|
||||
};
|
||||
networkmanager.ensureProfiles.profiles = {
|
||||
dhcp-bridge = {
|
||||
bridge.stp = false;
|
||||
connection = {
|
||||
id = "dhcp-bridge";
|
||||
interface-name = "br0";
|
||||
type = "bridge";
|
||||
};
|
||||
};
|
||||
slave-ethernet.connection = {
|
||||
controller = "br0";
|
||||
id = "slave-ethernet";
|
||||
port-type = "bridge";
|
||||
type = "ethernet";
|
||||
};
|
||||
static-bridge = {
|
||||
bridge.stp = false;
|
||||
connection = {
|
||||
id = "static-bridge";
|
||||
interface-name = "br0";
|
||||
type = "bridge";
|
||||
};
|
||||
ipv4 = {
|
||||
addresses = "10.2.0.1/16";
|
||||
method = "manual";
|
||||
};
|
||||
ipv6 = {
|
||||
addresses = "fc02::1/64";
|
||||
method = "manual";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
services = {
|
||||
dnsmasq.settings = {
|
||||
bind-dynamic = true;
|
||||
dhcp-boot = "efi/boot/BOOTX64.EFI";
|
||||
dhcp-range = [
|
||||
"10.2.0.2,10.2.255.254,12h"
|
||||
"fc02::2,fc02::ffff:ffff:ffff:ffff,12h"
|
||||
];
|
||||
enable-ra = true;
|
||||
enable-tftp = true;
|
||||
interface = "br0";
|
||||
tftp-root = "/srv/pxe/nixos/boot";
|
||||
};
|
||||
nfs.server = {
|
||||
enable = true;
|
||||
exports."/srv/pxe/export"."10.2.0.0/16" = [
|
||||
"fsid=0"
|
||||
"no_root_squash"
|
||||
"rw"
|
||||
];
|
||||
};
|
||||
};
|
||||
systemd = {
|
||||
services = {
|
||||
pxeboot = {
|
||||
before = [ "nfs-server.service" ];
|
||||
path = [ pkgs.util-linux ];
|
||||
preStop = ''
|
||||
cd /srv/pxe
|
||||
mountpoint -q export && umount export
|
||||
'';
|
||||
requiredBy = [ "nfs-server.service" ];
|
||||
script = ''
|
||||
cd /srv/pxe
|
||||
if [ ! -e export ]; then
|
||||
systemctl start pxeboot-install
|
||||
fi
|
||||
mountpoint -q export || mount -B --mkdir nixos export
|
||||
'';
|
||||
serviceConfig = {
|
||||
RemainAfterExit = true;
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
pxeboot-install = {
|
||||
path = with pkgs; [
|
||||
nix
|
||||
nixos-install
|
||||
];
|
||||
script = ''
|
||||
(printf '# Auto generated\n{\n boot.initrd.availableKernelModules = [\n'
|
||||
cd ${config.boot.kernelPackages.kernel.modules}/lib/modules/*/kernel/drivers/net/ethernet
|
||||
find -type f | sed 's/^.*\/\([^.]*\).*$/ "\1"/' | sort
|
||||
printf ' ];\n}\n') > /etc/nixos/bootable/ethernet.nix
|
||||
nixos-install --flake "/etc/nixos#nixos-bootpxe" \
|
||||
--no-channel-copy --no-root-passwd --root /srv/pxe/nixos
|
||||
'';
|
||||
};
|
||||
};
|
||||
tmpfiles.rules = [ "d /srv/pxe/nixos/boot" ];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue