os/modules/x-os/networking.nix

87 lines
2 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
psCfg = config.pub-solar;
cfg = psCfg.x-os;
in
{
options.pub-solar.x-os = {
binaryCaches = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Binary caches to use.";
};
publicKeys = mkOption {
type = types.listOf types.str;
default = [ ];
description = "Public keys of binary caches.";
};
iwdConfig = mkOption {
type = with types; nullOr (attrsOf (attrsOf (oneOf [ bool int str ])));
default = null;
description = "Configuratoin of iNet Wireless Daemon.";
};
};
config = {
networking.networkmanager = {
# Enable networkmanager. REMEMBER to add yourself to group in order to use nm related stuff.
enable = true;
};
# Customized binary caches list (with fallback to official binary cache)
nix.binaryCaches = cfg.binaryCaches;
nix.binaryCachePublicKeys = cfg.publicKeys;
# These entries get added to /etc/hosts
networking.hosts = {
"127.0.0.1" = mkIf psCfg.printing.enable [ "cups.local" ];
};
# ha reverse proxy for local services like cups
services.haproxy.enable = true;
services.haproxy.config = ''
global
maxconn 4096
# user http
# group http
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
timeout connect 5000
timeout client 50000
timeout server 50000
log 127.0.0.1 local0
log 127.0.0.1 local7 debug
option httpchk
frontend http
bind 0.0.0.0:80
acl is_cups hdr_end(host) -i cups.local
acl is_local dst 127.0.0.1
use_backend cups if is_cups is_local
frontend vnc
bind 0.0.0.0:5901
mode tcp
use_backend vnc
backend cups
server cups unix@/run/cups/cups.sock
backend vnc
server vnc unix@/run/wayvnc.sock
'';
};
}